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
ConstructorDescriptionConstraintExceptionHandler
(io.micronaut.http.server.exceptions.response.ErrorResponseProcessor<?> responseProcessor) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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)
-
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 interfaceio.micronaut.http.server.exceptions.ExceptionHandler<jakarta.validation.ConstraintViolationException,
io.micronaut.http.HttpResponse<?>>
-
buildMessage
Builds a message based on the provided violation.- Parameters:
violation
- The constraint violation- Returns:
- The violation message
-