Skip to content

Commit 8d1573a

Browse files
committed
Application::processException(), $onError and $onShutdown handles Throwable errors (BC break)
1 parent 31ae841 commit 8d1573a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Application/Application.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Application extends Nette\Object
2727
/** @var callable[] function (Application $sender); Occurs before the application loads presenter */
2828
public $onStartup;
2929

30-
/** @var callable[] function (Application $sender, \Exception $e = NULL); Occurs before the application shuts down */
30+
/** @var callable[] function (Application $sender, \Exception|\Throwable $e = NULL); Occurs before the application shuts down */
3131
public $onShutdown;
3232

3333
/** @var callable[] function (Application $sender, Request $request); Occurs when a new request is received */
@@ -39,7 +39,7 @@ class Application extends Nette\Object
3939
/** @var callable[] function (Application $sender, IResponse $response); Occurs when a new response is ready for dispatch */
4040
public $onResponse;
4141

42-
/** @var callable[] function (Application $sender, \Exception $e); Occurs when an unhandled exception occurs in the application */
42+
/** @var callable[] function (Application $sender, \Exception|\Throwable $e); Occurs when an unhandled exception occurs in the application */
4343
public $onError;
4444

4545
/** @var Request[] */
@@ -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
}
@@ -153,9 +158,10 @@ public function processRequest(Request $request)
153158

154159

155160
/**
161+
* @param \Exception|\Throwable
156162
* @return void
157163
*/
158-
public function processException(\Exception $e)
164+
public function processException($e)
159165
{
160166
if (!$e instanceof BadRequestException && $this->httpResponse instanceof Nette\Http\Response) {
161167
$this->httpResponse->warnOnBuffer = FALSE;

0 commit comments

Comments
 (0)