Skip to content

Commit

Permalink
🐛 fix(exceptions): Fix data type error handling in AuthError constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
sudoskys committed Jan 30, 2024
1 parent efc5fd9 commit fbf55ad
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/novelai_python/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class APIError(NovelAiError):
response: Union[Dict[str, Any], str] = None

def __init__(self, message: str, request: dict, response: Union[dict, str], status_code: str) -> None:
if not isinstance(response, dict):
response = {"error": f"data type error, should be dict, but got {type(response)}"}
if not isinstance(request, dict):
request = {"error": f"data type error, should be dict, but got {type(request)}"}
self.request = request
self.message = message
self.code = status_code
Expand All @@ -34,5 +38,5 @@ class AuthError(APIError):
AuthError is raised when the API returns an error.
"""

def __init__(self, message: str, request: Any, response: Any, status_code: str) -> None:
def __init__(self, message: str, request: dict, response: Union[dict, str], status_code: str) -> None:
super().__init__(message, request, response, status_code)

0 comments on commit fbf55ad

Please sign in to comment.