N
N
ne-programmist2021-12-20 17:37:36
symfony
ne-programmist, 2021-12-20 17:37:36

How to catch an exception in symphony when {id} is not found in the route?

tell me how to catch an exception in symphony when {id} is not found in the route?

[2021-12-20 17:27:12] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "App\Entity\User object not found by the @ParamConverter annotation."

to avoid logging

/**
     * @Route("/{id}", name="user", requirements={"id"="\d+"})
     */
    public function index(User $user): Response
    {

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Gordinskiy, 2021-12-20
@DmitriyGordinskiy

Write a custom error handler

I
Igor Kaznov, 2022-04-04
@Malverdo

monolog has the ability to disable certain logs monolog.yaml
can more easily set default to id

defaults:
        id: 0

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question