diff --git a/app/services/twilio/incoming_message_service.rb b/app/services/twilio/incoming_message_service.rb index f28192f4e..e379b6e0d 100644 --- a/app/services/twilio/incoming_message_service.rb +++ b/app/services/twilio/incoming_message_service.rb @@ -127,7 +127,7 @@ class Twilio::IncomingMessageService def download_attachment_file download_with_auth - rescue Down::Error => e + rescue Down::Error, Down::ClientError => e handle_download_attachment_error(e) end @@ -141,12 +141,10 @@ class Twilio::IncomingMessageService # This is just a temporary workaround since some users have not yet enabled media protection. We will remove this in the future. def handle_download_attachment_error(error) - Rails.logger.info "Error downloading attachment from Twilio: #{error.message}" - if error.message.include?('401 Unauthorized') - Down.download(params[:MediaUrl0]) - else - ChatwootExceptionTracker.new(error, account: @inbox.account).capture_exception - nil - end + Rails.logger.info "Error downloading attachment from Twilio: #{error.message}: Retrying" + Down.download(params[:MediaUrl0]) + rescue StandardError => e + Rails.logger.info "Error downloading attachment from Twilio: #{e.message}: Skipping" + nil end end