-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathHandler.php
More file actions
40 lines (33 loc) · 1.17 KB
/
Handler.php
File metadata and controls
40 lines (33 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace App\Exceptions;
use Psr\Http\Message\ResponseInterface;
use Rareloop\Lumberjack\Exceptions\Handler as LumberjackHandler;
use Rareloop\Lumberjack\Facades\Config;
use Rareloop\Lumberjack\Facades\Log;
use Rareloop\Lumberjack\Http\Responses\TimberResponse;
use Timber\Timber;
use Psr\Http\Message\ServerRequestInterface;
use Throwable;
class Handler extends LumberjackHandler
{
protected $dontReport = [];
public function report(Throwable $e)
{
parent::report($e);
}
public function render(ServerRequestInterface $request, Throwable $e): ResponseInterface
{
// Provide a customisable error rendering when not in debug mode
try {
if (Config::get('app.debug') === false) {
$data = Timber::get_context();
$data['exception'] = $e;
return new TimberResponse('templates/errors/whoops.twig', $data, 500);
}
} catch (Throwable $customRenderException) {
// Something went wrong in the custom renderer, log it and show the default rendering
Log::error($customRenderException);
}
return parent::render($request, $e);
}
}