Skip to content

Commit

Permalink
Merge pull request #94 from ecmwf-projects/COPDS-1390-exceptions
Browse files Browse the repository at this point in the history
Enable human-readable exception message by Processing API
  • Loading branch information
mcucchi9 authored Jan 24, 2024
2 parents aa32761 + 8908a71 commit bc53399
Showing 1 changed file with 7 additions and 0 deletions.
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

0 comments on commit bc53399

Please sign in to comment.