Skip to content

Commit b80b489

Browse files
committed
Fix bug
1 parent 72467ba commit b80b489

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Middleware/ErrorCatcher.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
use Psr\Http\Server\MiddlewareInterface;
1414
use Psr\Http\Server\RequestHandlerInterface;
1515
use Throwable;
16-
use Yiisoft\ErrorHandler\Event\ApplicationError;
1716
use Yiisoft\ErrorHandler\ErrorHandler;
17+
use Yiisoft\ErrorHandler\Event\ApplicationError;
1818
use Yiisoft\ErrorHandler\HeadersProvider;
1919
use Yiisoft\ErrorHandler\Renderer\HeaderRenderer;
2020
use Yiisoft\ErrorHandler\Renderer\HtmlRenderer;
@@ -128,13 +128,14 @@ public function forceContentType(string $contentType): self
128128

129129
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
130130
{
131-
$t = null;
132131
try {
133132
return $handler->handle($request);
134133
} catch (Throwable $t) {
135-
$this->eventDispatcher?->dispatch(new ApplicationError($t));
136-
} finally {
137-
/** @psalm-suppress PossiblyNullArgument $t is set in catch() statement */
134+
try {
135+
$this->eventDispatcher?->dispatch(new ApplicationError($t));
136+
} catch (Throwable $e) {
137+
// ignore exceptions thrown in event handlers
138+
}
138139
return $this->generateErrorResponse($t, $request);
139140
}
140141
}

0 commit comments

Comments
 (0)