Skip to content

Commit 1fa5ece

Browse files
committed
WebProfilerBundle: catch RouteNotFoundException instead of generic \Exception
1 parent de671f4 commit 1fa5ece

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag;
1919
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
2020
use Symfony\Component\HttpKernel\Profiler\Profiler;
21+
use Symfony\Component\Routing\Exception\RouteNotFoundException;
2122
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
2223

2324
/**
@@ -202,8 +203,8 @@ public function toolbarAction(Request $request, $token)
202203
$url = null;
203204
try {
204205
$url = $this->generator->generate('_profiler', array('token' => $token));
205-
} catch (\Exception $e) {
206-
// the profiler is not enabled
206+
} catch (RouteNotFoundException $e) {
207+
// the named route doesn't exist => the profiler is not enabled
207208
}
208209

209210
return new Response($this->twig->render('@WebProfiler/Profiler/toolbar.html.twig', array(

0 commit comments

Comments
 (0)