Skip to content

Commit 119d287

Browse files
committed
RoutingPanel: display exception thrown in match()
1 parent e7ba639 commit 119d287

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Bridges/ApplicationTracy/RoutingPanel.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ private function analyse(Nette\Application\IRouter $router, string $module = '')
105105
}
106106

107107
$matched = 'no';
108-
$request = $router->match($this->httpRequest);
108+
$request = $e = null;
109+
try {
110+
$request = $router->match($this->httpRequest);
111+
} catch (\Exception $e) {
112+
}
109113
if ($request) {
110114
$request->setPresenterName($module . $request->getPresenterName());
111115
$matched = 'may';
@@ -123,6 +127,7 @@ private function analyse(Nette\Application\IRouter $router, string $module = '')
123127
'mask' => $router instanceof Routers\Route ? $router->getMask() : null,
124128
'request' => $request,
125129
'module' => rtrim($module, ':'),
130+
'error' => $e,
126131
];
127132
}
128133

src/Bridges/ApplicationTracy/templates/RoutingPanel.panel.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ use Tracy\Dumper;
7979
<?php foreach ($params as $key => $value): ?>
8080
<?= htmlspecialchars((string) $key, ENT_IGNORE, 'UTF-8'), '&nbsp;=&nbsp;', is_string($value) ? htmlspecialchars($value, ENT_IGNORE, 'UTF-8') . '<br />' : Dumper::toHtml($value, [Dumper::COLLAPSE => true, Dumper::LIVE => true]) ?>
8181
<?php endforeach ?>
82-
</code><?php endif ?></td>
82+
</code><?php elseif ($router['error']): ?><strong><?= htmlspecialchars($router['error']->getMessage(), ENT_IGNORE, 'UTF-8') ?></strong><?php endif ?></td>
8383
</tr>
8484
<?php endforeach ?>
8585
</tbody>

0 commit comments

Comments
 (0)