Final Class Yiisoft\ErrorHandler\Renderer\JsonRenderer
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
Formats throwable into JSON string.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| render() | Yiisoft\ |
|
| renderVerbose() | Yiisoft\ |
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| CONTENT_TYPE | 'application/json' | Yiisoft\ |
Method Details
| public Yiisoft\ | ||
| $t | Throwable | |
| $request | ?\ |
|
public function render(Throwable $t, ?ServerRequestInterface $request = null): ErrorData
{
return new ErrorData(
json_encode(
[
'message' => self::DEFAULT_ERROR_MESSAGE,
],
JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES,
),
[Header::CONTENT_TYPE => self::CONTENT_TYPE],
);
}
| public Yiisoft\ | ||
| $t | Throwable | |
| $request | ?\ |
|
public function renderVerbose(Throwable $t, ?ServerRequestInterface $request = null): ErrorData
{
return new ErrorData(
json_encode(
[
'type' => $t::class,
'message' => $t->getMessage(),
'code' => $t->getCode(),
'file' => $t->getFile(),
'line' => $t->getLine(),
'trace' => $t->getTrace(),
],
JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_INVALID_UTF8_SUBSTITUTE | JSON_PARTIAL_OUTPUT_ON_ERROR,
),
[Header::CONTENT_TYPE => self::CONTENT_TYPE],
);
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.