Skip to content

Instantly share code, notes, and snippets.

@b1a9id
Created September 13, 2020 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b1a9id/057714c7615793291409cd76cd9a4f25 to your computer and use it in GitHub Desktop.
Save b1a9id/057714c7615793291409cd76cd9a4f25 to your computer and use it in GitHub Desktop.
springdoc-openapiサンプルのGlobalControllerHandler.java
@RestControllerAdvice
public class GlobalControllerHandler {
@ExceptionHandler(RuntimeException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ResponseEntity<ErrorResponse> handleNotFoundException(RuntimeException e) {
return ResponseEntity.of(Optional.of(new ErrorResponse(e.getMessage())));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment