Class ResourceRegistryExceptionMapper
java.lang.Object
org.gcube.informationsystem.resourceregistry.rest.providers.ResourceRegistryExceptionMapper
- All Implemented Interfaces:
jakarta.ws.rs.ext.ExceptionMapper<org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException>
@Provider
public class ResourceRegistryExceptionMapper
extends Object
implements jakarta.ws.rs.ext.ExceptionMapper<org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException>
Global JAX-RS
ExceptionMapper that maps every ResourceRegistryException
thrown by the service into an HTTP error Response.
The mapped status code is derived from the exception's concrete subtype (e.g.
NotFoundException → 404, AlreadyPresentException/
ContextLifecycleException/SchemaViolationException → 409,
AvailableInAnotherContextException/ContextVisibilityException → 403),
defaulting to 400 Bad Request for any other subtype and 500 Internal Server
Error for a bare ResourceRegistryException. The body is built by
ErrorResponseBody; the stack trace is always logged server-side.
- Author:
- Luca Frosini (ISTI - CNR)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjakarta.ws.rs.core.ResponsetoResponse(org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException exception) Maps the given exception to an HTTP errorResponse: selects the status code from the exception's concrete subtype (see the class Javadoc), always logs the stack trace, and sets the error body throughErrorResponseBody.
-
Constructor Details
-
ResourceRegistryExceptionMapper
public ResourceRegistryExceptionMapper()
-
-
Method Details
-
toResponse
public jakarta.ws.rs.core.Response toResponse(org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException exception) Maps the given exception to an HTTP errorResponse: selects the status code from the exception's concrete subtype (see the class Javadoc), always logs the stack trace, and sets the error body throughErrorResponseBody.- Specified by:
toResponsein interfacejakarta.ws.rs.ext.ExceptionMapper<org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException>- Parameters:
exception- the exception to map- Returns:
- the mapped HTTP error response
-