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

Enable human-readable exception message by Processing API #94

Merged
merged 3 commits into from
Jan 24, 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
7 changes: 7 additions & 0 deletions cads_broker/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import cacholote
import sqlalchemy as sa
import sqlalchemy.exc
import sqlalchemy.orm.exc
import sqlalchemy_utils
import structlog
Expand All @@ -31,6 +32,10 @@ class NoResultFound(Exception):
pass


class InvalidRequestID(Exception):
pass


class AdaptorProperties(BaseModel):
"""Adaptor Metadata ORM model."""

Expand Down Expand Up @@ -544,6 +549,8 @@ def get_request(
SystemRequest.request_uid == request_uid
)
return session.scalars(statement).one()
except sqlalchemy.exc.DataError:
raise InvalidRequestID(f"Invalid request_uid {request_uid}")
except sqlalchemy.orm.exc.NoResultFound:
logger.exception("get_request failed")
raise NoResultFound(f"No request found with request_uid {request_uid}")
Expand Down
Loading