Skip to content

Commit 973ce77

Browse files
committed
__toString, Application::run() and router serialization handles Throwable errors
1 parent b38ca7c commit 973ce77

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

src/Application/Application.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,19 @@ public function run()
8181
$this->processRequest($this->createInitialRequest());
8282
$this->onShutdown($this);
8383

84+
} catch (\Throwable $e) {
8485
} catch (\Exception $e) {
86+
}
87+
if (isset($e)) {
8588
$this->onError($this, $e);
8689
if ($this->catchExceptions && $this->errorPresenter) {
8790
try {
8891
$this->processException($e);
8992
$this->onShutdown($this, $e);
9093
return;
9194

95+
} catch (\Throwable $e) {
96+
$this->onError($this, $e);
9297
} catch (\Exception $e) {
9398
$this->onError($this, $e);
9499
}

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)