-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from cased/rick/cas-1945-cli-to-match-web-func…
…tionality-deploy Enable branch deploy functionality.
- Loading branch information
Showing
5 changed files
with
138 additions
and
125 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from typing import Any, Optional | ||
|
||
|
||
class CasedAPIError(Exception): | ||
def __init__( | ||
self, message: str, status_code: Optional[int] = None, response_body: Any = None | ||
): | ||
""" | ||
Initialize the CasedAPIError. | ||
Args: | ||
message (str): The error message. | ||
status_code (Optional[int]): The HTTP status code of the failed request. | ||
response_body (Any): The response body from the failed request. | ||
""" | ||
self.message = message | ||
self.status_code = status_code | ||
self.response_body = response_body | ||
super().__init__(self.message) | ||
|
||
# TODO: make this specific based on status codes returned from our API, | ||
# right now it is too generic. | ||
def __str__(self): | ||
"""Return a string representation of the error.""" | ||
error_msg = self.message | ||
if self.status_code: | ||
error_msg += f" (Status code: {self.status_code})" | ||
if self.response_body: | ||
error_msg += f"\nResponse body: {self.response_body}" | ||
return error_msg |
Oops, something went wrong.