Module utility.exception.mapper
Class PersistenceExceptionMapper
java.lang.Object
uk.co.jasonmarston.kiunzi.utility.exception.mapper.PersistenceExceptionMapper
- All Implemented Interfaces:
jakarta.ws.rs.ext.ExceptionMapper<uk.co.jasonmarston.kiunzi.utility.domain.exception.PersistenceException>
@Provider
public class PersistenceExceptionMapper
extends Object
implements jakarta.ws.rs.ext.ExceptionMapper<uk.co.jasonmarston.kiunzi.utility.domain.exception.PersistenceException>
Maps
PersistenceException instances to HTTP 500 responses.
This mapper exposes persistence-layer failures as a generic server error to the client while preserving the exception message in the response body.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjakarta.ws.rs.core.ResponsetoResponse(uk.co.jasonmarston.kiunzi.utility.domain.exception.PersistenceException ex) Converts the supplied persistence exception into an HTTP response.
-
Constructor Details
-
PersistenceExceptionMapper
public PersistenceExceptionMapper()Creates a mapper for persistence exceptions.
-
-
Method Details
-
toResponse
public jakarta.ws.rs.core.Response toResponse(uk.co.jasonmarston.kiunzi.utility.domain.exception.PersistenceException ex) Converts the supplied persistence exception into an HTTP response.- Specified by:
toResponsein interfacejakarta.ws.rs.ext.ExceptionMapper<uk.co.jasonmarston.kiunzi.utility.domain.exception.PersistenceException>- Parameters:
ex- the persistence exception raised while processing the request- Returns:
- an HTTP 500 response containing an
ErrorResponsebody
-