From 23a41aebadbe13e8992856c6be84ce6d01de0175 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 14 Jan 2023 15:42:03 +0300 Subject: Configure test coverage reports --- src/main/java/com/juick/www/api/Index.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/main/java/com/juick/www/api') diff --git a/src/main/java/com/juick/www/api/Index.java b/src/main/java/com/juick/www/api/Index.java index 921ebca4..7430c22d 100644 --- a/src/main/java/com/juick/www/api/Index.java +++ b/src/main/java/com/juick/www/api/Index.java @@ -19,6 +19,7 @@ package com.juick.www.api; import io.swagger.v3.oas.annotations.Hidden; +import jakarta.validation.ConstraintViolationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; @@ -56,4 +57,8 @@ public class Index { ServletUriComponentsBuilder.fromCurrentRequestUri().build().toUriString()); return ResponseEntity.badRequest().body("Invalid media type"); } + @ExceptionHandler(ConstraintViolationException.class) + public ResponseEntity badRequest(final ConstraintViolationException exception) { + return ResponseEntity.badRequest().body(exception.getMessage()); + } } -- cgit v1.2.3