Class WebApplicationExceptionMapper
java.lang.Object
org.gcube.informationsystem.resourceregistry.rest.providers.WebApplicationExceptionMapper
- All Implemented Interfaces:
jakarta.ws.rs.ext.ExceptionMapper<jakarta.ws.rs.WebApplicationException>
@Provider
public class WebApplicationExceptionMapper
extends Object
implements jakarta.ws.rs.ext.ExceptionMapper<jakarta.ws.rs.WebApplicationException>
Global JAX-RS
ExceptionMapper giving the JSON error body of the service to the
WebApplicationExceptions: the 401 and 403 of the Policy Enforcement
Points, and the errors of the JAX-RS runtime itself (e.g. 404 for an unknown path,
405). Without it, the container answers them with its own HTML error page.
The status and the headers of the exception's response are kept (e.g. the
WWW-Authenticate challenge of a 401); the body is built by
ErrorResponseBody from the exception's message. A response that already carries an
entity, or whose status is not an error, is returned unchanged.
- Author:
- Luca Frosini (ISTI - CNR)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjakarta.ws.rs.core.ResponsetoResponse(jakarta.ws.rs.WebApplicationException exception) Maps the given exception to an HTTP errorResponsewith the service's JSON error body.
-
Constructor Details
-
WebApplicationExceptionMapper
public WebApplicationExceptionMapper()
-
-
Method Details
-
toResponse
public jakarta.ws.rs.core.Response toResponse(jakarta.ws.rs.WebApplicationException exception) Maps the given exception to an HTTP errorResponsewith the service's JSON error body.- Specified by:
toResponsein interfacejakarta.ws.rs.ext.ExceptionMapper<jakarta.ws.rs.WebApplicationException>- Parameters:
exception- the exception to map- Returns:
- the mapped HTTP error response
-