diff --git a/src/main/java/org/example/crimearchive/exceptions/GlobalExceptionHandler.java b/src/main/java/org/example/crimearchive/exceptions/GlobalExceptionHandler.java index d31e596..953d83d 100644 --- a/src/main/java/org/example/crimearchive/exceptions/GlobalExceptionHandler.java +++ b/src/main/java/org/example/crimearchive/exceptions/GlobalExceptionHandler.java @@ -1,14 +1,13 @@ package org.example.crimearchive.exceptions; import org.springframework.http.HttpStatus; +import org.springframework.security.authorization.AuthorizationDeniedException; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.servlet.resource.NoResourceFoundException; -import java.nio.file.AccessDeniedException; - @ControllerAdvice public class GlobalExceptionHandler { @@ -54,9 +53,9 @@ public String handleRuntime(RuntimeException ex, Model model) { ); } - @ExceptionHandler(AccessDeniedException.class) + @ExceptionHandler(AuthorizationDeniedException.class) @ResponseStatus(HttpStatus.FORBIDDEN) - public String handleAccessDenied(AccessDeniedException ex, Model model) { + public String handleAccessDenied(AuthorizationDeniedException ex, Model model) { return buildError( model, HttpStatus.FORBIDDEN.value(),