Skip to content

Commit

Permalink
fix: add ResponseEntityHandlers for auth exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
mpgxvii committed Apr 16, 2024
1 parent 326c68f commit 8e46f5a
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.context.request.WebRequest;
import radar.spring.auth.exception.AuthorizationFailedException;
import radar.spring.auth.exception.ResourceForbiddenException;

import java.time.Instant;

Expand All @@ -27,6 +29,15 @@ public final ResponseEntity<ErrorDetails> handleUnhandledException(Exception ex,
return new ResponseEntity<>(error, status);
}

@ExceptionHandler(AuthorizationFailedException.class)
public final ResponseEntity<ErrorDetails> handleAuthorizationFailedException(Exception ex, WebRequest request) throws Exception {
return handleEntityWithCause(ex, request);
}

@ExceptionHandler(ResourceForbiddenException.class)
public final ResponseEntity<ErrorDetails> handleResourceForbiddenException(Exception ex, WebRequest request) throws Exception {
return handleEntityWithCause(ex, request);
}

@ExceptionHandler(InvalidProjectDetailsException.class)
public final ResponseEntity<ErrorDetails> handleInvalidProjectDetailsException(Exception ex, WebRequest request) throws Exception {
Expand Down

0 comments on commit 8e46f5a

Please sign in to comment.