From 9efe20415c13560028c066fbe46b80f9dd590d0c Mon Sep 17 00:00:00 2001 From: Ajay Raj Date: Mon, 24 Jun 2024 17:01:01 -0700 Subject: [PATCH] carry over change to remove runtime error on twilio 401 --- vocode/streaming/telephony/client/twilio_client.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/vocode/streaming/telephony/client/twilio_client.py b/vocode/streaming/telephony/client/twilio_client.py index 254318cf9..97e8a9f7d 100644 --- a/vocode/streaming/telephony/client/twilio_client.py +++ b/vocode/streaming/telephony/client/twilio_client.py @@ -14,6 +14,10 @@ class TwilioBadRequestException(ValueError): pass +class TwilioException(ValueError): + pass + + class TwilioClient(AbstractTelephonyClient): def __init__( self, @@ -64,10 +68,11 @@ async def create_call( ) raise TwilioBadRequestException( "Telephony provider rejected call; this is usually due to a bad/malformed number. " - "If this persists, and you're sure that the number is well-formed, " - "please contact us." ) - raise RuntimeError(f"Failed to create call: {response.status} {response.reason}") + else: + raise TwilioException( + f"Twilio failed to create call: {response.status} {response.reason}" + ) response = await response.json() return response["sid"]