Lets say I have 3 different bundles.
I am adding to event listeners to each bundle. When there is any exception in Bundle1, then Bundle2 and Bundle3 should not listen it.
I have tested it adding to each bundle eventlistener but when there is any error in Bundle2 then Bundle1 will listen try to handle it as well.
How to handle this situation?
if needed any code then here is my service.yaml in bundle:
kernel.listener.test1bundle.exceptionlistener:
class: App\test1bundle\EventListener\ExceptionListener
tags:
- { name: kernel.event_listener, event: kernel.exception}
and here is my exception listener:
public function onKernelException(GetResponseForExceptionEvent $event)
{
// You get the exception object from the received event
$exception = $event->getException();
$message = [
"errors" => [
[
"title" => "Internal error in test1 bundle",
"detail" => $exception->getMessage()
]
]
];
$response = new JsonResponse();
$response->setData($message);
$response->headers->set('Content-Type', 'application/problem+json');
$event->setResponse($response);
}
i read that it is possible just listen controller. But in that case will controller listener listen exceptions as well?