1
0
mirror of https://github.com/flarum/core.git synced 2025-10-17 09:46:14 +02:00
Files
php-flarum/src/Foundation/ErrorHandling/WhoopsFormatter.php
Franz Liedke 7dbdd8c024 Rename method
2019-08-20 20:08:01 +02:00

35 lines
1.0 KiB
PHP

<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Foundation\ErrorHandling;
use Franzl\Middleware\Whoops\WhoopsRunner;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
/**
* Handle errors using the Whoops error handler for debugging.
*
* Proper status codes for all known error types are returned. In addition,
* content negotiation is performed to return proper responses in various
* environments such as HTML frontends or API backends.
*
* Should only be used in debug mode (because Whoops may expose sensitive data).
*/
class WhoopsFormatter implements HttpFormatter
{
public function format(HandledError $error, Request $request): Response
{
return WhoopsRunner::handle($error->getException(), $request)
->withStatus($error->getStatusCode());
}
}