Created
February 1, 2023 21:02
-
-
Save ddanielsantos/c1e9fad06be63e2ce321d660284f8f54 to your computer and use it in GitHub Desktop.
due to the second method's argument, it skips the ControllerAdvice's error handling.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestMapping(value = "/comments", method = RequestMethod.POST, produces = "application/json") | |
public ResponseEntity<?> createComment(@RequestBody @Valid CommentForm body, BindingResult errors ) { | |
// if (errors.hasErrors()) { | |
// HashMap<String, List<String>> res = new HashMap<>(); | |
// | |
// List<String> errorList = errors | |
// .getFieldErrors() | |
// .stream() | |
// .map(DefaultMessageSourceResolvable::getDefaultMessage) | |
// .collect(Collectors.toList()); | |
// | |
// res.put("errors", errorList); | |
// | |
// return new ResponseEntity<>(HttpStatus.BAD_REQUEST); | |
// } | |
return new ResponseEntity<>(HttpStatus.OK); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment