Skip to content

Instantly share code, notes, and snippets.

@ddanielsantos
Created February 1, 2023 21:02
Show Gist options
  • Save ddanielsantos/c1e9fad06be63e2ce321d660284f8f54 to your computer and use it in GitHub Desktop.
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.
@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