Last active
May 12, 2023 01:11
-
-
Save kapresoft/68678f59798be7fd36dd4a96db9a132f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@ExceptionHandler(BadRequestException.class) | |
public ResponseEntity<HttpClientErrorException> handleBadRequest(BadRequestException ex, WebRequest req) { | |
ProblemDetail p = ProblemDetail.forStatus(ex.getStatusCode()); | |
URI type = new DefaultUriBuilderFactory() | |
.uriString("https://yoursite.acme.com/bad-request/{error-code}") | |
.build(Map.of("error-code", ex.getErrorCode())); | |
p.setDetail(ex.getStatusText()); | |
p.setTitle("Bad Request"); | |
p.setType(type); | |
p.setProperty("hint", "hint-value"); | |
return ResponseEntity.of(p).build(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment