Skip to content

Commit

Permalink
🐛 fix: improve error messages in API error handling
Browse files Browse the repository at this point in the history
Improve error messages in API error handling to provide better
context and information for debugging.
  • Loading branch information
sudoskys committed Apr 9, 2024
1 parent ea6ad89 commit bc4b69e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/novelai_python/sdk/ai/generate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,28 +184,28 @@ async def request(self,
message = _msg.get("message", "Unknown error")
if status_code == 400:
raise APIError(
"A validation error occured.",
f"A validation error occured. {message}",
request=request_data, code=status_code, response=_msg
)

elif status_code == 401:
raise APIError(
"Access Token is incorrect.",
f"Access Token is incorrect. {message}",
request=request_data, code=status_code, response=_msg
)
elif status_code == 402:
raise APIError(
"An active subscription is required to access this endpoint.",
f"An active subscription is required to access this endpoint. {message}",
request=request_data, code=status_code, response=_msg
)
elif status_code == 409:
raise APIError(
"A conflict error occured.",
f"A conflict error occured. {message}",
request=request_data, code=status_code, response=_msg
)
else:
raise APIError(
f"An unknown error occured.{response.status_code}",
f"An unknown error occured. {response.status_code} {message}",
request=request_data, code=status_code, response=_msg
)
else:
Expand Down

0 comments on commit bc4b69e

Please sign in to comment.