Skip to content

Commit 2e47b95

Browse files
author
Alice Williams
committed
Replace SymfonyExceptionHandler with Spatie Ignition
1 parent f10f397 commit 2e47b95

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"mindplay/middleman": "^3.1.0",
2424
"psr/log": "^1.1.4",
2525
"laminas/laminas-zendframework-bridge": "^1.7",
26-
"symfony/var-dumper": "^5.0||^6.3.6"
26+
"symfony/var-dumper": "^5.0||^6.3.6",
27+
"spatie/ignition": "^1.15"
2728
},
2829
"require-dev": {
2930
"phpunit/phpunit": "^9.6.13",

src/Exceptions/Handler.php

+11-6
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
namespace Rareloop\Lumberjack\Exceptions;
44

55
use Exception;
6+
use Laminas\Diactoros\Response\HtmlResponse;
67
use Psr\Http\Message\ResponseInterface;
78
use Psr\Http\Message\ServerRequestInterface;
89
use Rareloop\Lumberjack\Application;
910
use Rareloop\Lumberjack\Facades\Config;
10-
use Symfony\Component\Debug\ExceptionHandler as SymfonyExceptionHandler;
11-
use Symfony\Component\Debug\Exception\FlattenException;
12-
use Zend\Diactoros\Response\HtmlResponse;
11+
use Spatie\Ignition\Ignition;
1312

1413
class Handler implements HandlerInterface
1514
{
@@ -36,11 +35,17 @@ public function report(Exception $e)
3635

3736
public function render(ServerRequestInterface $request, Exception $e) : ResponseInterface
3837
{
39-
$e = FlattenException::create($e);
38+
$isDebug = Config::get('app.debug', false) === true;
4039

41-
$handler = new SymfonyExceptionHandler(Config::get('app.debug', false));
40+
$ignition = Ignition::make()->shouldDisplayException($isDebug)->register();
4241

43-
return new HtmlResponse($handler->getHtml($e), $e->getStatusCode(), $e->getHeaders());
42+
ob_start();
43+
44+
$ignition->handleException($e);
45+
46+
$html = ob_get_clean();
47+
48+
return new HtmlResponse($html);
4449
}
4550

4651
protected function shouldNotReport(Exception $e)

0 commit comments

Comments
 (0)