Skip to content

Commit

Permalink
feat: error msg updated
Browse files Browse the repository at this point in the history
  • Loading branch information
nitin-vavdiya committed Sep 18, 2023
1 parent 5a04a2e commit 2b305d2
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ ProblemDetail handleBadDataException(BadDataException e) {
*/
@ExceptionHandler(MethodArgumentNotValidException.class)
ProblemDetail handleValidation(MethodArgumentNotValidException e) {
ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, e.getMessage());
ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, ExceptionUtils.getMessage(e));
problemDetail.setTitle("Invalid data provided");
problemDetail.setProperty(TIMESTAMP, System.currentTimeMillis());
problemDetail.setProperty("errors", handleValidationError(e.getFieldErrors()));
Expand All @@ -134,7 +134,7 @@ ProblemDetail handleValidation(MethodArgumentNotValidException e) {
*/
@ExceptionHandler(ConstraintViolationException.class)
ProblemDetail handleValidation(ConstraintViolationException exception) {
ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, exception.getMessage());
ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, ExceptionUtils.getMessage(exception));
problemDetail.setTitle("Invalid data provided");
problemDetail.setProperty(TIMESTAMP, System.currentTimeMillis());
problemDetail.setProperty("errors", exception.getConstraintViolations().stream().map(ConstraintViolation::getMessage).toList());
Expand Down

0 comments on commit 2b305d2

Please sign in to comment.