exceptions
Common exceptions and handlers for DM Product Service.
Classes
Raised when the Bearer token has the wrong audience for this service. |
|
Raised when no Bearer token is present in the request. |
|
Raised when the requested path is outside the allowed storage base path. |
|
Raised when the caller is not authorised for a route. |
Functions
|
Decorator to convert internal exceptions to HTTP responses. |
Module Contents
- class exceptions.InvalidTokenAudience(aapi_url='', service='')
Bases:
fastapi.HTTPExceptionRaised when the Bearer token has the wrong audience for this service.
Returns an IVOA AuthVO 401 challenge with an exchange_url pointing to the AAPI token exchange endpoint so the client knows exactly how to obtain a service-scoped token.
- Parameters:
aapi_url (str) –
service (str) –
- class exceptions.MissingToken
Bases:
fastapi.HTTPExceptionRaised when no Bearer token is present in the request.
Returns an IVOA AuthVO 401 challenge. Extends HTTPException so that FastAPI handles it correctly whether raised from a route handler or a Depends() dependency.
- class exceptions.PathOutsideStorageArea(path)
Bases:
fastapi.HTTPExceptionRaised when the requested path is outside the allowed storage base path.
- Parameters:
path (str) –
- message = 'Path outside allowed storage area: Uninferable'
- class exceptions.PermissionDenied(message='You do not have permission to access this resource.')
Bases:
fastapi.HTTPExceptionRaised when the caller is not authorised for a route.
Extends HTTPException directly so it is handled correctly by FastAPI whether raised inside a route handler or inside a Depends() dependency.
- Parameters:
message (str) –
- message = 'You do not have permission to access this resource.'
- exceptions.handle_exceptions(func)
Decorator to convert internal exceptions to HTTP responses.