Skip to content

Commit

Permalink
Very much a work in progress towards a clean SB 3.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Aidan Whiteley committed Mar 21, 2024
1 parent 272b77f commit f4e80e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.3</version>
<version>3.2.4</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.AccessDeniedException;
Expand All @@ -18,6 +19,7 @@
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import org.springframework.web.servlet.resource.NoResourceFoundException;

import static org.springframework.http.HttpStatus.*;

Expand Down Expand Up @@ -107,6 +109,11 @@ public ApiExceptionData handleDefaultExceptions(Exception ex, WebRequest request
protected ResponseEntity<Object> handleExceptionInternal(Exception ex, Object body, HttpHeaders headers,
HttpStatusCode status, WebRequest request) {

if (ex instanceof NoResourceFoundException) {
API_LOGGER.info("Resource not found. This may well be expected: " + ex.getMessage());
return new ResponseEntity<>(HttpStatusCode.valueOf(NOT_FOUND.ordinal()));
}

API_LOGGER.error(
"The Spring framework rather than the application handled the following exception: {}", ex.getMessage(),
ex);
Expand Down

0 comments on commit f4e80e3

Please sign in to comment.