From 6dc5c8284713f4adda9af0a29a972088b440ddb2 Mon Sep 17 00:00:00 2001 From: Luishfs Date: Tue, 23 Apr 2024 13:38:03 -0300 Subject: [PATCH] Restricting HTTPError try/catch to only 20404 Twilio code errors --- source-twilio/source_twilio/streams.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source-twilio/source_twilio/streams.py b/source-twilio/source_twilio/streams.py index b177a184f6..daee91db13 100644 --- a/source-twilio/source_twilio/streams.py +++ b/source-twilio/source_twilio/streams.py @@ -243,10 +243,13 @@ def read_records( if record[self.cursor_field] >= self.state.get(self.cursor_field, self._start_date): self._cursor_value = record[self.cursor_field] yield record - except HTTPError: + except HTTPError as err: # Catching errors similar to # {"code": 20404, "message": "The requested resource /2010-04-01/Accounts/XXX/Usage/Records.json was not found"} - pass + if err.response.json()["code"] == 20404: + pass + else: + raise err class TwilioNestedStream(TwilioStream):