edq.core.errors
1import typing 2 3class UtilsError(Exception): 4 """ General errors raised from this library. """ 5 6class RetryError(UtilsError): 7 """ An error that came up after trying an operation for a specified number of times (e.g., network retries). """ 8 9 def __init__(self, base_message: str, attempts: int, retry_errors: typing.Union[typing.List[Exception], None] = None) -> None: 10 if (retry_errors is None): 11 retry_errors = [] 12 13 self.retry_errors: typing.List[Exception] = retry_errors 14 """ Any errors that occurred and prompted the retries. """ 15 16 message = f"Failed after {attempts} attempts: '{base_message}'." 17 if (len(self.retry_errors) > 0): 18 message += f" Errors encountered: {self.retry_errors}." 19 20 super().__init__(message) 21 22 def contains_instance(self, target_type: typing.Type) -> bool: 23 """ Check if one of the retry errors has the given type. """ 24 25 for retry_error in self.retry_errors: 26 if (isinstance(retry_error, target_type)): 27 return True 28 29 return False
class
UtilsError(builtins.Exception):
General errors raised from this library.
7class RetryError(UtilsError): 8 """ An error that came up after trying an operation for a specified number of times (e.g., network retries). """ 9 10 def __init__(self, base_message: str, attempts: int, retry_errors: typing.Union[typing.List[Exception], None] = None) -> None: 11 if (retry_errors is None): 12 retry_errors = [] 13 14 self.retry_errors: typing.List[Exception] = retry_errors 15 """ Any errors that occurred and prompted the retries. """ 16 17 message = f"Failed after {attempts} attempts: '{base_message}'." 18 if (len(self.retry_errors) > 0): 19 message += f" Errors encountered: {self.retry_errors}." 20 21 super().__init__(message) 22 23 def contains_instance(self, target_type: typing.Type) -> bool: 24 """ Check if one of the retry errors has the given type. """ 25 26 for retry_error in self.retry_errors: 27 if (isinstance(retry_error, target_type)): 28 return True 29 30 return False
An error that came up after trying an operation for a specified number of times (e.g., network retries).
RetryError( base_message: str, attempts: int, retry_errors: Optional[List[Exception]] = None)
10 def __init__(self, base_message: str, attempts: int, retry_errors: typing.Union[typing.List[Exception], None] = None) -> None: 11 if (retry_errors is None): 12 retry_errors = [] 13 14 self.retry_errors: typing.List[Exception] = retry_errors 15 """ Any errors that occurred and prompted the retries. """ 16 17 message = f"Failed after {attempts} attempts: '{base_message}'." 18 if (len(self.retry_errors) > 0): 19 message += f" Errors encountered: {self.retry_errors}." 20 21 super().__init__(message)
def
contains_instance(self, target_type: Type) -> bool:
23 def contains_instance(self, target_type: typing.Type) -> bool: 24 """ Check if one of the retry errors has the given type. """ 25 26 for retry_error in self.retry_errors: 27 if (isinstance(retry_error, target_type)): 28 return True 29 30 return False
Check if one of the retry errors has the given type.