diff options
Diffstat (limited to '.venv/lib/python3.12/site-packages/storage3/exceptions.py')
-rw-r--r-- | .venv/lib/python3.12/site-packages/storage3/exceptions.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/storage3/exceptions.py b/.venv/lib/python3.12/site-packages/storage3/exceptions.py new file mode 100644 index 00000000..098b9d11 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/storage3/exceptions.py @@ -0,0 +1,33 @@ +from typing import TypedDict + +from .utils import StorageException + + +class StorageApiErrorDict(TypedDict): + name: str + message: str + status: int + + +class StorageApiError(StorageException): + """Error raised when an operation on the storage API fails.""" + + def __init__(self, message: str, code: str, status: int) -> None: + error_message = "{{'statusCode': {}, 'error': {}, 'message': {}}}".format( + status, + code, + message, + ) + super().__init__(error_message) + self.name = "StorageApiError" + self.message = message + self.code = code + self.status = status + + def to_dict(self) -> StorageApiErrorDict: + return { + "name": self.name, + "code": self.code, + "message": self.message, + "status": self.status, + } |