exceptions ========== .. py:module:: exceptions .. autoapi-nested-parse:: Common exceptions and handlers for DM Product Service. Classes ------- .. autoapisummary:: exceptions.InvalidTokenAudience exceptions.MissingToken exceptions.PathOutsideStorageArea exceptions.PermissionDenied Functions --------- .. autoapisummary:: exceptions.handle_exceptions Module Contents --------------- .. py:class:: InvalidTokenAudience(aapi_url = '', service = '') Bases: :py:obj:`fastapi.HTTPException` Raised 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. .. py:class:: MissingToken Bases: :py:obj:`fastapi.HTTPException` Raised 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. .. py:class:: PathOutsideStorageArea(path) Bases: :py:obj:`fastapi.HTTPException` Raised when the requested path is outside the allowed storage base path. .. py:attribute:: message :value: 'Path outside allowed storage area: Uninferable' .. py:class:: PermissionDenied(message = 'You do not have permission to access this resource.') Bases: :py:obj:`fastapi.HTTPException` Raised 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. .. py:attribute:: message :value: 'You do not have permission to access this resource.' .. py:function:: handle_exceptions(func) Decorator to convert internal exceptions to HTTP responses.