From e0e69701297bd1680e523485b27116d51149f99b Mon Sep 17 00:00:00 2001 From: dabuek Date: Thu, 23 Apr 2026 21:57:12 +0200 Subject: [PATCH] wrong type of access denied exception before --- .../crimearchive/exceptions/GlobalExceptionHandler.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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(),