@@ -331,32 +331,41 @@ def read_records(
331
331
pagination_complete = False
332
332
333
333
next_page_token = None
334
- with AirbyteSentry .start_transaction ("read_records" , self .name ), AirbyteSentry .start_transaction_span ("read_records" ):
335
- while not pagination_complete :
336
-
337
- properties_list = list (self .properties .keys ())
338
- if properties_list :
339
- stream_records , response = self ._read_stream_records (
340
- properties_list = properties_list ,
341
- stream_slice = stream_slice ,
342
- stream_state = stream_state ,
343
- next_page_token = next_page_token ,
344
- )
345
- records = [value for key , value in stream_records .items ()]
346
- else :
347
- response = self .handle_request (stream_slice = stream_slice , stream_state = stream_state , next_page_token = next_page_token )
348
- records = self ._transform (self .parse_response (response , stream_state = stream_state , stream_slice = stream_slice ))
349
-
350
- if self .filter_old_records :
351
- records = self ._filter_old_records (records )
352
- yield from records
353
-
354
- next_page_token = self .next_page_token (response )
355
- if not next_page_token :
356
- pagination_complete = True
357
-
358
- # Always return an empty generator just in case no records were ever yielded
359
- yield from []
334
+ try :
335
+ with AirbyteSentry .start_transaction ("read_records" , self .name ), AirbyteSentry .start_transaction_span ("read_records" ):
336
+ while not pagination_complete :
337
+
338
+ properties_list = list (self .properties .keys ())
339
+ if properties_list :
340
+ stream_records , response = self ._read_stream_records (
341
+ properties_list = properties_list ,
342
+ stream_slice = stream_slice ,
343
+ stream_state = stream_state ,
344
+ next_page_token = next_page_token ,
345
+ )
346
+ records = [value for key , value in stream_records .items ()]
347
+ else :
348
+ response = self .handle_request (
349
+ stream_slice = stream_slice , stream_state = stream_state , next_page_token = next_page_token
350
+ )
351
+ records = self ._transform (self .parse_response (response , stream_state = stream_state , stream_slice = stream_slice ))
352
+
353
+ if self .filter_old_records :
354
+ records = self ._filter_old_records (records )
355
+ yield from records
356
+
357
+ next_page_token = self .next_page_token (response )
358
+ if not next_page_token :
359
+ pagination_complete = True
360
+
361
+ # Always return an empty generator just in case no records were ever yielded
362
+ yield from []
363
+ except requests .exceptions .HTTPError as e :
364
+ status_code = e .response .status_code
365
+ if status_code == 403 :
366
+ raise RuntimeError (f"Invalid permissions for { self .name } . Please ensure the all scopes are authorized for." )
367
+ else :
368
+ raise e
360
369
361
370
@staticmethod
362
371
def _convert_datetime_to_string (dt : pendulum .datetime , declared_format : str = None ) -> str :
0 commit comments