chore: Handle the Twilio exception in sentry
Fix trying to extract the Sid from non created message. Fixes #3029
This commit is contained in:
parent
c504067e2b
commit
dddab0bbce
2 changed files with 4 additions and 2 deletions
|
@ -9,9 +9,9 @@ class Twilio::SendOnTwilioService < Base::SendOnChannelService
|
|||
begin
|
||||
twilio_message = client.messages.create(**message_params)
|
||||
rescue Twilio::REST::TwilioError => e
|
||||
Rails.logger.info "Twilio Error: #{e.message}"
|
||||
Sentry.capture_exception(e)
|
||||
end
|
||||
message.update!(source_id: twilio_message.sid)
|
||||
message.update!(source_id: twilio_message.sid) if twilio_message
|
||||
end
|
||||
|
||||
def message_params
|
||||
|
|
|
@ -28,6 +28,7 @@ describe Twilio::SendOnTwilioService do
|
|||
message = create(:message, message_type: 'outgoing', private: true, inbox: twilio_inbox, account: account)
|
||||
::Twilio::SendOnTwilioService.new(message: message).perform
|
||||
expect(twilio_client).not_to have_received(:messages)
|
||||
expect(message.reload.source_id).to be_nil
|
||||
end
|
||||
|
||||
it 'if inbox channel is not twilio' do
|
||||
|
@ -40,6 +41,7 @@ describe Twilio::SendOnTwilioService do
|
|||
message = create(:message, message_type: 'incoming', inbox: twilio_inbox, account: account)
|
||||
::Twilio::SendOnTwilioService.new(message: message).perform
|
||||
expect(twilio_client).not_to have_received(:messages)
|
||||
expect(message.reload.source_id).to be_nil
|
||||
end
|
||||
|
||||
it 'if message has an source id' do
|
||||
|
|
Loading…
Reference in a new issue