Reputation: 7579
My site is logging uncaught exceptions when users try routes that don't exist. The log looks like this:
[2013-05-30 15:47:38] myapp.ERROR: Symfony\Component\HttpKernel\Exception\NotFoundHttpException: No route found for "GET /a/made/up/url" (uncaught exception) at /home/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php line 92 [] []
Is this normal? Or is there some way that I should be catching the exception?
My error handling code looks like this:
$app->error(function (\Exception $e, $code) use ($app) {
$app['monolog']->addDebug($e);
// Some app-specific code
$globals = $app['select_globals']();
switch ($code) {
case 404:
return $app['twig']->render('404.phtml', array('globals' => $globals));
break;
default:
return $app['twig']->render('error.phtml', array('globals' => $globals));
}
});
Upvotes: 0
Views: 2946
Reputation: 8645
Yes this is totally normal, Symfony2 (and also Silex) logs exceptions, and a not found page is considered as an exception !
Look at this documentation : http://symfony.com/doc/current/book/controller.html#managing-errors-and-404-pages
When you want to force a 404 inside your action, you are invoking explicitly NotFoundHttpException !
Upvotes: 3