Skip to content
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

Type-cast inputs for general Error #280

Merged
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
11 changes: 7 additions & 4 deletions optimade/server/exception_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@ def general_exception(
debug_info[f"_{CONFIG.provider.prefix}_traceback"] = tb

try:
http_response_code = exc.status_code
http_response_code = int(exc.status_code)
except AttributeError:
http_response_code = status_code
http_response_code = int(status_code)

try:
title = exc.title
title = str(exc.title)
except AttributeError:
title = str(exc.__class__.__name__)

detail = getattr(exc, "detail", str(exc))
try:
detail = str(exc.detail)
except AttributeError:
detail = str(exc)

if errors is None:
errors = [OptimadeError(detail=detail, status=http_response_code, title=title)]
Expand Down