-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new storage error class (#313)
- Loading branch information
1 parent
9d9d3a2
commit f040f10
Showing
5 changed files
with
57 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
} |