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 1111use Symfony \Component \HttpKernel \Event \ExceptionEvent ;
1212use Symfony \Component \HttpKernel \Exception \AccessDeniedHttpException ;
1313use Symfony \Component \HttpKernel \Exception \HttpExceptionInterface ;
14+ use Symfony \Component \Security \Core \Exception \AccessDeniedException ;
1415use Symfony \Component \Validator \Exception \ValidatorException ;
1516
1617class ExceptionListener
@@ -46,6 +47,11 @@ public function onKernelException(ExceptionEvent $event): void
4647 'message ' => $ exception ->getMessage (),
4748 ], 400 );
4849 $ event ->setResponse ($ response );
50+ } elseif ($ exception instanceof AccessDeniedException) {
51+ $ response = new JsonResponse ([
52+ 'message ' => $ exception ->getMessage (),
53+ ], 403 );
54+ $ event ->setResponse ($ response );
4955 } elseif ($ exception instanceof Exception) {
5056 $ response = new JsonResponse ([
5157 'message ' => $ exception ->getMessage (),
You can’t perform that action at this time.
0 commit comments