|
|
@@ -7,6 +7,7 @@ import org.springframework.validation.FieldError;
|
|
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
|
+import org.springframework.web.servlet.resource.NoResourceFoundException;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.HashMap;
|
|
|
@@ -49,6 +50,19 @@ public class GlobalExceptionHandler {
|
|
|
|
|
|
return ResponseEntity.badRequest().body(response);
|
|
|
}
|
|
|
+
|
|
|
+ @ExceptionHandler(NoResourceFoundException.class)
|
|
|
+ public ResponseEntity<Map<String, Object>> handleNoResourceFoundException(NoResourceFoundException ex) {
|
|
|
+ log.warn("Resource not found: {}", ex.getMessage());
|
|
|
+
|
|
|
+ Map<String, Object> response = new HashMap<>();
|
|
|
+ response.put("timestamp", LocalDateTime.now());
|
|
|
+ response.put("status", HttpStatus.NOT_FOUND.value());
|
|
|
+ response.put("error", "Not Found");
|
|
|
+ response.put("message", ex.getMessage());
|
|
|
+
|
|
|
+ return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
|
|
+ }
|
|
|
|
|
|
@ExceptionHandler(Exception.class)
|
|
|
public ResponseEntity<Map<String, Object>> handleGenericException(Exception ex) {
|