diff --git a/spring-boot/exception-handling/src/main/java/io/reflectoring/exception/exception/GlobalExceptionHandler.java b/spring-boot/exception-handling/src/main/java/io/reflectoring/exception/exception/GlobalExceptionHandler.java index 283c253..fb3a5aa 100644 --- a/spring-boot/exception-handling/src/main/java/io/reflectoring/exception/exception/GlobalExceptionHandler.java +++ b/spring-boot/exception-handling/src/main/java/io/reflectoring/exception/exception/GlobalExceptionHandler.java @@ -41,12 +41,14 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler { @ExceptionHandler(NoSuchElementFoundException.class) @ResponseStatus(HttpStatus.NOT_FOUND) public ResponseEntity handleNoSuchElementFoundException(NoSuchElementFoundException itemNotFoundException, WebRequest request) { + log.error("Failed to find the requested element", itemNotFoundException); return buildErrorResponse(itemNotFoundException, HttpStatus.NOT_FOUND, request); } - @ExceptionHandler(RuntimeException.class) + @ExceptionHandler(Exception.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) - public ResponseEntity handleAllUncaughtException(RuntimeException exception, WebRequest request) { + public ResponseEntity handleAllUncaughtException(Exception exception, WebRequest request) { + log.error("Unknown error occurred", exception); return buildErrorResponse(exception, "Unknown error occurred", HttpStatus.INTERNAL_SERVER_ERROR, request); }