@@ -27,7 +27,7 @@ class Application extends Nette\Object
27
27
/** @var callable[] function (Application $sender); Occurs before the application loads presenter */
28
28
public $ onStartup ;
29
29
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 */
31
31
public $ onShutdown ;
32
32
33
33
/** @var callable[] function (Application $sender, Request $request); Occurs when a new request is received */
@@ -39,7 +39,7 @@ class Application extends Nette\Object
39
39
/** @var callable[] function (Application $sender, IResponse $response); Occurs when a new response is ready for dispatch */
40
40
public $ onResponse ;
41
41
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 */
43
43
public $ onError ;
44
44
45
45
/** @var Request[] */
@@ -81,14 +81,19 @@ public function run()
81
81
$ this ->processRequest ($ this ->createInitialRequest ());
82
82
$ this ->onShutdown ($ this );
83
83
84
+ } catch (\Throwable $ e ) {
84
85
} catch (\Exception $ e ) {
86
+ }
87
+ if (isset ($ e )) {
85
88
$ this ->onError ($ this , $ e );
86
89
if ($ this ->catchExceptions && $ this ->errorPresenter ) {
87
90
try {
88
91
$ this ->processException ($ e );
89
92
$ this ->onShutdown ($ this , $ e );
90
93
return ;
91
94
95
+ } catch (\Throwable $ e ) {
96
+ $ this ->onError ($ this , $ e );
92
97
} catch (\Exception $ e ) {
93
98
$ this ->onError ($ this , $ e );
94
99
}
@@ -153,9 +158,10 @@ public function processRequest(Request $request)
153
158
154
159
155
160
/**
161
+ * @param \Exception|\Throwable
156
162
* @return void
157
163
*/
158
- public function processException (\ Exception $ e )
164
+ public function processException ($ e )
159
165
{
160
166
if (!$ e instanceof BadRequestException && $ this ->httpResponse instanceof Nette \Http \Response) {
161
167
$ this ->httpResponse ->warnOnBuffer = FALSE ;
0 commit comments