0 follower

Final Class Yiisoft\ErrorHandler\Renderer\XmlRenderer

InheritanceYiisoft\ErrorHandler\Renderer\XmlRenderer
ImplementsYiisoft\ErrorHandler\ThrowableRendererInterface

Formats throwable into XML string.

Constants

Hide inherited constants

Constant Value Description Defined By
CONTENT_TYPE 'application/xml' Yiisoft\ErrorHandler\Renderer\XmlRenderer
DEFAULT_ERROR_MESSAGE 'An internal server error occurred.' Yiisoft\ErrorHandler\ThrowableRendererInterface

Method Details

Hide inherited methods

render() public method

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
{
    $content = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>';
    $content .= "\n<error>\n";
    $content .= $this->tag('message', self::DEFAULT_ERROR_MESSAGE);
    $content .= '</error>';
    return new ErrorData(
        $content,
        [Header::CONTENT_TYPE => self::CONTENT_TYPE],
    );
}

            
renderVerbose() public method

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
{
    $content = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>';
    $content .= "\n<error>\n";
    $content .= $this->tag('type', $t::class);
    $content .= $this->tag('message', $this->cdata($t->getMessage()));
    $content .= $this->tag('code', $this->cdata((string) $t->getCode()));
    $content .= $this->tag('file', $t->getFile());
    $content .= $this->tag('line', (string) $t->getLine());
    $content .= $this->tag('trace', $t->getTraceAsString());
    $content .= '</error>';
    return new ErrorData(
        $content,
        [Header::CONTENT_TYPE => self::CONTENT_TYPE],
    );
}