blob: 098b9d11338f4d0d85034549edf818de30f14fba (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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,
}
|