Skip to content

feat: add invalid file error code #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions workflowai/core/domain/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"internal_error",
# The request was invalid
"bad_request",
"invalid_file",
],
str, # Using as a fallback to avoid validation error if an error code is added to the API
]
Expand Down Expand Up @@ -82,18 +83,18 @@ def __str__(self):
def from_response(cls, response: Response):
try:
response_json = response.json()
r_error = response_json.get("error",{})
r_error = response_json.get("error", {})
error_message = response_json.get("detail", {}) or r_error.get("message", "Unknown Error")
details = r_error.get("details", {})
details = r_error.get("details", {})
error_code = r_error.get("code", "unknown_error")
status_code = response.status_code
task_run_id = r_error.get("task_run_id", None)
except JSONDecodeError:
error_message = "Unknown error"
details = {"raw": response.content.decode()}
error_code ="unknown_error"
error_code = "unknown_error"
status_code = response.status_code
task_run_id=None
task_run_id = None

return cls(
response=response,
Expand All @@ -105,4 +106,3 @@ def from_response(cls, response: Response):
),
task_run_id=task_run_id,
)

Loading