当用户尝试不存在的路由时,我的站点正在记录未捕获的异常。日志如下所示:
[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 [] []
这是正常的吗?或者有什么方法可以让我捕捉到异常?
我的错误处理代码如下所示:
$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));
}
});