mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-12-22 04:16:41 +03:00
24 lines
No EOL
566 B
PHP
24 lines
No EOL
566 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
class ExceptionMiddleware implements Middleware
|
|
{
|
|
private Logger $logger;
|
|
|
|
public function __construct(Logger $logger)
|
|
{
|
|
$this->logger = $logger;
|
|
}
|
|
|
|
public function __invoke(Request $request, $next): Response
|
|
{
|
|
try {
|
|
return $next($request);
|
|
} catch (\Throwable $e) {
|
|
$this->logger->error('Exception in ExceptionMiddleware', ['e' => $e]);
|
|
|
|
return new Response(render(__DIR__ . '/../templates/exception.html.php', ['e' => $e]), 500);
|
|
}
|
|
}
|
|
} |