for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Whoops - php errors for cool kids
* @author Filipe Dobreira <http://github.com/filp>
*/
namespace ByJG\RestServer\Whoops;
use Whoops\Exception\Formatter;
use Whoops\Handler\Handler;
use Whoops\Handler\JsonResponseHandler as OriginalJsonErrorHandler;
* Catches an exception and converts it to a JSON
* response. Additionally can also return exception
* frames for consumption by an API.
class JsonResponseErrorHandler extends OriginalJsonErrorHandler
{
use WhoopsDebugTrait;
use WhoopsHeaderTrait;
* @return int
public function handle()
$response = array(
'error' => Formatter::formatExceptionAsDataArray(
$this->getInspector(),
$this->addTraceToOutput()
),
);
$debug = $this->getDataTable();
if (count($debug) > 0) {
$response["debug"] = $debug;
}
$this->setProperHeader($this->getException());
echo json_encode($response, defined('JSON_PARTIAL_OUTPUT_ON_ERROR') ? JSON_PARTIAL_OUTPUT_ON_ERROR : 0);
return Handler::QUIT;