Skip to content

Commit

Permalink
Twilio 400 errors are now not retryable
Browse files Browse the repository at this point in the history
  • Loading branch information
mchlwellman committed Dec 2, 2024
1 parent e69c34f commit 003a08e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions app/clients/sms/twilio.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
RETRYABLE_STATUS_REASON,
TWILIO_PROVIDER,
)
from app.exceptions import InvalidProviderException


# https://www.twilio.com/docs/messaging/api/message-resource#message-status-values
Expand Down Expand Up @@ -235,11 +234,13 @@ def send_sms(

return message.sid
except TwilioRestException as e:
if e.status == 400 and 'phone number' in e.msg:
self.logger.exception('Twilio send SMS request for %s failed', reference)
raise InvalidProviderException from e
else:
raise
self.logger.exception('Twilio send SMS request for %s failed', reference)
raise NonRetryableException('Twilio request failed') from e
# if e.status == 400 and 'phone number' in e.msg:
# self.logger.exception('Twilio send SMS request for %s failed', reference)
# raise InvalidProviderException from e
# else:
# raise
except:
self.logger.exception('Twilio send SMS request for %s failed', reference)
raise
Expand Down

0 comments on commit 003a08e

Please sign in to comment.