Skip to content

Commit 31ae841

Browse files
committed
__toString and router serialization handles Throwable errors
1 parent 11a8d33 commit 31ae841

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/Application/UI/Link.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ public function __toString()
9090
try {
9191
return (string) $this->component->link($this->destination, $this->params);
9292

93+
} catch (\Throwable $e) {
9394
} catch (\Exception $e) {
95+
}
96+
if (isset($e)) {
9497
if (func_num_args()) {
9598
throw $e;
9699
}

src/Bridges/ApplicationDI/RoutingExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class)
6868
$method = $class->getMethod(Nette\DI\Container::getMethodName($this->prefix('router')));
6969
try {
7070
$router = serialize(eval($method->getBody()));
71+
} catch (\Throwable $e) {
72+
throw new Nette\DI\ServiceCreationException('Unable to cache router due to error: ' . $e->getMessage(), 0, $e);
7173
} catch (\Exception $e) {
7274
throw new Nette\DI\ServiceCreationException('Unable to cache router due to error: ' . $e->getMessage(), 0, $e);
7375
}

src/Bridges/ApplicationLatte/Template.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ public function __toString()
6060
{
6161
try {
6262
return $this->latte->renderToString($this->file, $this->params);
63+
} catch (\Throwable $e) {
6364
} catch (\Exception $e) {
65+
}
66+
if (isset($e)) {
6467
if (func_num_args()) {
6568
throw $e;
6669
}

0 commit comments

Comments
 (0)