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
    Constructor
    Description
    Creates a mapper for persistence exceptions.
  • Method Summary

    Modifier and Type
    Method
    Description
    jakarta.ws.rs.core.Response
    toResponse(uk.co.jasonmarston.kiunzi.utility.domain.exception.PersistenceException ex)
    Converts the supplied persistence exception into an HTTP response.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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:
      toResponse in interface jakarta.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 ErrorResponse body