Last active
May 12, 2023 01:10
-
-
Save kapresoft/154d48098e52134703b7a2120b7dd4f8 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(NotFoundException.class) | |
public ResponseEntity<HttpClientErrorException> handleNotFound(NotFoundException ex, WebRequest req) { | |
ProblemDetail p = ProblemDetail.forStatus(ex.getStatusCode()); | |
URI type = new DefaultUriBuilderFactory() | |
.uriString("https://yoursite.acme.com/not-found/{error-code}") | |
.build(Map.of("error-code", ex.getErrorCode())); | |
p.setDetail(ex.getStatusText()); | |
p.setTitle("Object not found"); | |
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