Class DomainInvariantViolationExceptionMapper

java.lang.Object
uk.co.jasonmarston.kiunzi.utility.exception.mapper.DomainInvariantViolationExceptionMapper
All Implemented Interfaces:
jakarta.ws.rs.ext.ExceptionMapper<uk.co.jasonmarston.kiunzi.utility.validator.DomainInvariantViolationException>

@Provider public class DomainInvariantViolationExceptionMapper extends Object implements jakarta.ws.rs.ext.ExceptionMapper<uk.co.jasonmarston.kiunzi.utility.validator.DomainInvariantViolationException>
Maps DomainInvariantViolationException instances to HTTP 409 responses with detailed validation errors.

Each domain violation is converted into a ValidationErrorResponse.Violation entry so clients can identify the field or property that caused the conflict.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a mapper for domain invariant violations.
  • Method Summary

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

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DomainInvariantViolationExceptionMapper

      public DomainInvariantViolationExceptionMapper()
      Creates a mapper for domain invariant violations.
  • Method Details

    • toResponse

      public jakarta.ws.rs.core.Response toResponse(uk.co.jasonmarston.kiunzi.utility.validator.DomainInvariantViolationException ex)
      Converts the supplied domain invariant violation into an HTTP response.
      Specified by:
      toResponse in interface jakarta.ws.rs.ext.ExceptionMapper<uk.co.jasonmarston.kiunzi.utility.validator.DomainInvariantViolationException>
      Parameters:
      ex - the domain invariant violation raised while processing the request
      Returns:
      an HTTP 409 response containing a ValidationErrorResponse body