Answer the question
In order to leave comments, you need to log in
How to properly handle my exception not found symfony 4?
How to properly handle your exception? If I do something like this
public function onKernelException(GetResponseForExceptionEvent $event): void
{
$exception = $event->getException();
$response = $event->getResponse();
//dd($exception, $response);
if ($exception instanceof NotFoundException) {
$event->setResponse(new Response($exception->getUserMessage(), $exception->getCode()));
}
}
public function onKernelException(GetResponseForExceptionEvent $event): void
{
$exception = $event->getException();
$response = $event->getResponse();
//dd($exception, $response);
if ($exception instanceof NotFoundException) {
$event->setException(new NotFoundHttpException($exception->getUserMessage()));
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question