airbyte_cdk.sources.streams.http.exceptions
1# 2# Copyright (c) 2023 Airbyte, Inc., all rights reserved. 3# 4 5 6from typing import Optional, Union 7 8import requests 9 10 11class BaseBackoffException(requests.exceptions.HTTPError): 12 def __init__( 13 self, 14 request: requests.PreparedRequest, 15 response: Optional[Union[requests.Response, Exception]], 16 error_message: str = "", 17 ): 18 if isinstance(response, requests.Response): 19 error_message = ( 20 error_message 21 or f"Request URL: {request.url}, Response Code: {response.status_code}, Response Text: {response.text}" 22 ) 23 super().__init__(error_message, request=request, response=response) 24 else: 25 error_message = error_message or f"Request URL: {request.url}, Exception: {response}" 26 super().__init__(error_message, request=request, response=None) 27 28 29class RequestBodyException(Exception): 30 """ 31 Raised when there are issues in configuring a request body 32 """ 33 34 35class UserDefinedBackoffException(BaseBackoffException): 36 """ 37 An exception that exposes how long it attempted to backoff 38 """ 39 40 def __init__( 41 self, 42 backoff: Union[int, float], 43 request: requests.PreparedRequest, 44 response: Optional[Union[requests.Response, Exception]], 45 error_message: str = "", 46 ): 47 """ 48 :param backoff: how long to backoff in seconds 49 :param request: the request that triggered this backoff exception 50 :param response: the response that triggered the backoff exception 51 """ 52 self.backoff = backoff 53 super().__init__(request=request, response=response, error_message=error_message) 54 55 56class DefaultBackoffException(BaseBackoffException): 57 pass 58 59 60class RateLimitBackoffException(BaseBackoffException): 61 pass
class
BaseBackoffException(requests.exceptions.HTTPError):
12class BaseBackoffException(requests.exceptions.HTTPError): 13 def __init__( 14 self, 15 request: requests.PreparedRequest, 16 response: Optional[Union[requests.Response, Exception]], 17 error_message: str = "", 18 ): 19 if isinstance(response, requests.Response): 20 error_message = ( 21 error_message 22 or f"Request URL: {request.url}, Response Code: {response.status_code}, Response Text: {response.text}" 23 ) 24 super().__init__(error_message, request=request, response=response) 25 else: 26 error_message = error_message or f"Request URL: {request.url}, Exception: {response}" 27 super().__init__(error_message, request=request, response=None)
An HTTP error occurred.
BaseBackoffException( request: requests.models.PreparedRequest, response: Union[requests.models.Response, Exception, NoneType], error_message: str = '')
13 def __init__( 14 self, 15 request: requests.PreparedRequest, 16 response: Optional[Union[requests.Response, Exception]], 17 error_message: str = "", 18 ): 19 if isinstance(response, requests.Response): 20 error_message = ( 21 error_message 22 or f"Request URL: {request.url}, Response Code: {response.status_code}, Response Text: {response.text}" 23 ) 24 super().__init__(error_message, request=request, response=response) 25 else: 26 error_message = error_message or f"Request URL: {request.url}, Exception: {response}" 27 super().__init__(error_message, request=request, response=None)
class
RequestBodyException(builtins.Exception):
30class RequestBodyException(Exception): 31 """ 32 Raised when there are issues in configuring a request body 33 """
Raised when there are issues in configuring a request body
36class UserDefinedBackoffException(BaseBackoffException): 37 """ 38 An exception that exposes how long it attempted to backoff 39 """ 40 41 def __init__( 42 self, 43 backoff: Union[int, float], 44 request: requests.PreparedRequest, 45 response: Optional[Union[requests.Response, Exception]], 46 error_message: str = "", 47 ): 48 """ 49 :param backoff: how long to backoff in seconds 50 :param request: the request that triggered this backoff exception 51 :param response: the response that triggered the backoff exception 52 """ 53 self.backoff = backoff 54 super().__init__(request=request, response=response, error_message=error_message)
An exception that exposes how long it attempted to backoff
UserDefinedBackoffException( backoff: Union[int, float], request: requests.models.PreparedRequest, response: Union[requests.models.Response, Exception, NoneType], error_message: str = '')
41 def __init__( 42 self, 43 backoff: Union[int, float], 44 request: requests.PreparedRequest, 45 response: Optional[Union[requests.Response, Exception]], 46 error_message: str = "", 47 ): 48 """ 49 :param backoff: how long to backoff in seconds 50 :param request: the request that triggered this backoff exception 51 :param response: the response that triggered the backoff exception 52 """ 53 self.backoff = backoff 54 super().__init__(request=request, response=response, error_message=error_message)
Parameters
- backoff: how long to backoff in seconds
- request: the request that triggered this backoff exception
- response: the response that triggered the backoff exception
An HTTP error occurred.
Inherited Members
An HTTP error occurred.