[ErrorCatcher] Pretty print JSON formatted errors
This commit is contained in:
parent
e3927b6294
commit
ab926d2065
@ -47,6 +47,6 @@ class JsonErrorRenderer implements ErrorRendererInterface
|
||||
$content['exceptions'] = $exception->toArray();
|
||||
}
|
||||
|
||||
return (string) json_encode($content);
|
||||
return (string) json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_LINE_TERMINATORS | JSON_PRESERVE_ZERO_FRACTION);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,17 @@ class JsonErrorRendererTest extends TestCase
|
||||
public function testRender()
|
||||
{
|
||||
$exception = FlattenException::createFromThrowable(new \RuntimeException('Foo'));
|
||||
$expected = '{"title":"Internal Server Error","status":500,"detail":"Foo","exceptions":[{"message":"Foo","class":"RuntimeException","trace":';
|
||||
$expected = <<<JSON
|
||||
{
|
||||
"title": "Internal Server Error",
|
||||
"status": 500,
|
||||
"detail": "Foo",
|
||||
"exceptions": [
|
||||
{
|
||||
"message": "Foo",
|
||||
"class": "RuntimeException",
|
||||
"trace":
|
||||
JSON;
|
||||
|
||||
$this->assertStringStartsWith($expected, (new JsonErrorRenderer())->render($exception));
|
||||
}
|
||||
|
Reference in New Issue
Block a user