Final Class Yiisoft\ErrorHandler\Renderer\PlainTextRenderer
| Inheritance | Yiisoft\ErrorHandler\Renderer\PlainTextRenderer |
|---|---|
| Implements | Yiisoft\ErrorHandler\ThrowableRendererInterface |
Formats throwable into plain text string.
Public Methods
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| DEFAULT_ERROR_MESSAGE | 'An internal server error occurred.' | Yiisoft\ErrorHandler\ThrowableRendererInterface |
Method Details
| public mixed __construct ( string $contentType = 'text/plain' ) | ||
| $contentType | string | |
public function __construct(
private readonly string $contentType = 'text/plain',
) {
}
| public Yiisoft\ErrorHandler\ErrorData render ( Throwable $t, \Psr\Http\Message\ServerRequestInterface|null $request = null ) | ||
| $t | Throwable | |
| $request | \Psr\Http\Message\ServerRequestInterface|null | |
public function render(Throwable $t, ?ServerRequestInterface $request = null): ErrorData
{
return new ErrorData(
self::DEFAULT_ERROR_MESSAGE,
[Header::CONTENT_TYPE => $this->contentType],
);
}
| public Yiisoft\ErrorHandler\ErrorData renderVerbose ( Throwable $t, \Psr\Http\Message\ServerRequestInterface|null $request = null ) | ||
| $t | Throwable | |
| $request | \Psr\Http\Message\ServerRequestInterface|null | |
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()
);
}
Signup or Login in order to comment.