Skip to content

Commit 82d1e1a

Browse files
committed
Fix case where handler can be a console exception handler
1 parent c974049 commit 82d1e1a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Twig/TwigServiceProvider.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@
66

77
use Exception;
88
use Illuminate\Contracts\Debug\ExceptionHandler;
9+
use Illuminate\Foundation\Exceptions\Handler;
910
use Illuminate\Support\ServiceProvider;
11+
use Override;
1012

1113
final class TwigServiceProvider extends ServiceProvider
1214
{
13-
#[\Override]
15+
#[Override]
1416
public function register(): void
1517
{
16-
$this->app->make(ExceptionHandler::class)->map(Exception::class, fn (Exception $e) => $this->app->make(TwigMapper::class)->map($e));
18+
$handler = $this->app->make(ExceptionHandler::class);
19+
20+
if ($handler instanceof Handler) {
21+
$handler->map(Exception::class, fn (Exception $e) => $this->app->make(TwigMapper::class)->map($e));
22+
}
1723
}
1824
}

0 commit comments

Comments
 (0)