@@ 13-40 (lines=28) @@ | ||
10 | */ |
|
11 | namespace Infuse; |
|
12 | ||
13 | class ExceptionHandler |
|
14 | { |
|
15 | use HasApp; |
|
16 | ||
17 | /** |
|
18 | * @param Request $req |
|
19 | * @param Response $res |
|
20 | * @param \Exception $e |
|
21 | * |
|
22 | * @return Response |
|
23 | */ |
|
24 | public function __invoke($req, $res, \Exception $e) |
|
25 | { |
|
26 | $this->app['logger']->error('An uncaught exception occurred while handling a request.', ['exception' => $e]); |
|
27 | ||
28 | if (ob_get_length() > 0) { |
|
29 | ob_end_clean(); |
|
30 | } |
|
31 | ||
32 | if ($req->isHtml()) { |
|
33 | $res->render(new View('exception', [ |
|
34 | 'title' => 'Internal Server Error', |
|
35 | 'exception' => $e, ])); |
|
36 | } |
|
37 | ||
38 | return $res->setCode(500); |
|
39 | } |
|
40 | } |
|
41 |
@@ 13-40 (lines=28) @@ | ||
10 | */ |
|
11 | namespace Infuse; |
|
12 | ||
13 | class PhpErrorHandler |
|
14 | { |
|
15 | use HasApp; |
|
16 | ||
17 | /** |
|
18 | * @param Request $req |
|
19 | * @param Response $res |
|
20 | * @param \Error $e |
|
21 | * |
|
22 | * @return Response |
|
23 | */ |
|
24 | public function __invoke($req, $res, \Error $e) |
|
25 | { |
|
26 | $this->app['logger']->error('A PHP error occurred while handling a request.', ['exception' => $e]); |
|
27 | ||
28 | if (ob_get_length() > 0) { |
|
29 | ob_end_clean(); |
|
30 | } |
|
31 | ||
32 | if ($req->isHtml()) { |
|
33 | $res->render(new View('php_error', [ |
|
34 | 'title' => 'Internal Server Error', |
|
35 | 'error' => $e, ])); |
|
36 | } |
|
37 | ||
38 | return $res->setCode(500); |
|
39 | } |
|
40 | } |
|
41 |