File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change 11
11
use Symfony \Component \HttpKernel \Event \ExceptionEvent ;
12
12
use Symfony \Component \HttpKernel \Exception \AccessDeniedHttpException ;
13
13
use Symfony \Component \HttpKernel \Exception \HttpExceptionInterface ;
14
+ use Symfony \Component \Security \Core \Exception \AccessDeniedException ;
14
15
use Symfony \Component \Validator \Exception \ValidatorException ;
15
16
16
17
class ExceptionListener
@@ -46,6 +47,11 @@ public function onKernelException(ExceptionEvent $event): void
46
47
'message ' => $ exception ->getMessage (),
47
48
], 400 );
48
49
$ event ->setResponse ($ response );
50
+ } elseif ($ exception instanceof AccessDeniedException) {
51
+ $ response = new JsonResponse ([
52
+ 'message ' => $ exception ->getMessage (),
53
+ ], 403 );
54
+ $ event ->setResponse ($ response );
49
55
} elseif ($ exception instanceof Exception) {
50
56
$ response = new JsonResponse ([
51
57
'message ' => $ exception ->getMessage (),
You can’t perform that action at this time.
0 commit comments