Final Class Yiisoft\ErrorHandler\Renderer\PlainTextRenderer
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
Formats throwable into plain text string.
Public Methods
Method Details
| public mixed __construct ( string $contentType = 'text/plain' ) | ||
| $contentType | string | |
public function __construct(
private readonly string $contentType = 'text/plain',
) {}
| public Yiisoft\ | ||
| $t | Throwable | |
| $request | ?\ |
|
public function render(Throwable $t, ?ServerRequestInterface $request = null): ErrorData
{
return new ErrorData(
self::DEFAULT_ERROR_MESSAGE,
[Header::CONTENT_TYPE => $this->contentType],
);
}
| public Yiisoft\ | ||
| $t | Throwable | |
| $request | ?\ |
|
public function renderVerbose(Throwable $t, ?ServerRequestInterface $request = null): ErrorData
{
return new ErrorData(
self::throwableToString($t),
[Header::CONTENT_TYPE => $this->contentType],
);
}
| public static string throwableToString ( Throwable $t ) | ||
| $t | Throwable | |
public static function throwableToString(Throwable $t): string
{
return sprintf(
<<<TEXT
%s with message "%s"
in %s:%s
Stack trace:
%s
TEXT,
$t::class,
$t->getMessage(),
$t->getFile(),
$t->getLine(),
$t->getTraceAsString(),
);
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.