Answer the question
In order to leave comments, you need to log in
How to write a single uncaught error handler?
I am using php 7.x + Symfony 3.x + FOSRestBundle + JsonApi.
I read the documentation - all their examples are tightly tied to Twig, which I threw out of the project for good and, accordingly, solutions from there are not suitable.
Then I read the FOSRestBundle documentation and app/config/config.yml
did this:
fos_rest:
exception:
enabled: true
exception_controller: 'AppBundle\Controller\ExceptionController::showAction'
codes:
'Symfony\Component\HttpKernel\Exception\ConflictHttpException': 409
throw new BadRequestHttpException();
return new Response('Page not found.', Response::HTTP_NOT_FOUND);
$someObject->someFunctionThatDoesNotExists();
set_error_handler
+ set_exception_handler
+ to catch unhandled errors register_shutdown_function
and worked with them in one place. How is it accepted in Symfony? Who needs to be redefined so that no error (except for unrecoverable php fatal) passes by in some strange format not defined by me?
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