Class UnexpectedExceptionMapper

java.lang.Object
org.gcube.informationsystem.resourceregistry.rest.providers.UnexpectedExceptionMapper
All Implemented Interfaces:
jakarta.ws.rs.ext.ExceptionMapper<Exception>

@Provider public class UnexpectedExceptionMapper extends Object implements jakarta.ws.rs.ext.ExceptionMapper<Exception>
Global JAX-RS ExceptionMapper for any exception no more specific mapper handles (ResourceRegistryExceptionMapper, WebApplicationExceptionMapper): a 500 Internal Server Error with the service's JSON error body instead of the container's HTML page.

The stack trace is logged; the body carries only the generic message, never the exception's own, which may expose internals.

Author:
Luca Frosini (ISTI - CNR)
  • Constructor Details

    • UnexpectedExceptionMapper

      public UnexpectedExceptionMapper()
  • Method Details

    • toResponse

      public jakarta.ws.rs.core.Response toResponse(Exception exception)
      Maps the given exception to a 500 Internal Server Error with the generic JSON error body.
      Specified by:
      toResponse in interface jakarta.ws.rs.ext.ExceptionMapper<Exception>
      Parameters:
      exception - the exception to map
      Returns:
      the mapped HTTP error response