Class ConstraintExceptionHandler

java.lang.Object
io.micronaut.validation.exceptions.ConstraintExceptionHandler
All Implemented Interfaces:
io.micronaut.http.server.exceptions.ExceptionHandler<jakarta.validation.ConstraintViolationException,io.micronaut.http.HttpResponse<?>>

@Produces @Singleton @Requires(classes={jakarta.validation.ConstraintViolationException.class,io.micronaut.http.server.exceptions.ExceptionHandler.class}) public class ConstraintExceptionHandler extends Object implements io.micronaut.http.server.exceptions.ExceptionHandler<jakarta.validation.ConstraintViolationException,io.micronaut.http.HttpResponse<?>>
Default ExceptionHandler for ConstraintViolationException.
Since:
1.0
Author:
Graeme Rocher
  • Constructor Summary

    Constructors
    Constructor
    Description
    ConstraintExceptionHandler(io.micronaut.http.server.exceptions.response.ErrorResponseProcessor<?> responseProcessor)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected String
    buildMessage(jakarta.validation.ConstraintViolation<?> violation)
    Builds a message based on the provided violation.
    io.micronaut.http.HttpResponse<?>
    handle(io.micronaut.http.HttpRequest request, jakarta.validation.ConstraintViolationException exception)
     

    Methods inherited from class java.lang.Object

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

    • ConstraintExceptionHandler

      @Inject public ConstraintExceptionHandler(io.micronaut.http.server.exceptions.response.ErrorResponseProcessor<?> responseProcessor)
      Constructor.
      Parameters:
      responseProcessor - Error Response Processor
  • Method Details

    • handle

      public io.micronaut.http.HttpResponse<?> handle(io.micronaut.http.HttpRequest request, jakarta.validation.ConstraintViolationException exception)
      Specified by:
      handle in interface io.micronaut.http.server.exceptions.ExceptionHandler<jakarta.validation.ConstraintViolationException,io.micronaut.http.HttpResponse<?>>
    • buildMessage

      protected String buildMessage(jakarta.validation.ConstraintViolation<?> violation)
      Builds a message based on the provided violation.
      Parameters:
      violation - The constraint violation
      Returns:
      The violation message