lean-api/src/ApplicationStrategy/ThrowableHandler.php
2025-05-26 18:20:22 +00:00

23 lines
736 B
PHP

<?php
namespace Lean\Api\ApplicationStrategy;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
class ThrowableHandler extends \Lean\ApplicationStrategy\ThrowableHandler
{
public function process(
ServerRequestInterface $request,
RequestHandlerInterface $handler
): ResponseInterface {
try {
return $handler->handle($request);
} catch (\Throwable $ex) {
echo sprintf("%s in <strong>%s</strong> <pre>%s</pre>", $ex->getMessage(), $ex->getFile() . ":" . $ex->getLine(), $ex->getTraceAsString());
exit();
}
}