New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
4.x - Error renderers do not handle the displayErrorDetails uniformly #2746
Comments
We should try to keep it as consistent as possible if we can. The HTML and Plain Text renderers should behave the same and the JSON and XML should behave the same. I'm not sure what we should consider "error details". To me that would mean file, line and previous exception. Basic information should be Code (if other than 0) and Message. What do you think? |
In production it might be better not to reveal too much of details. Maybe the code is enough. I wouldn't make any difference between the content types. I suggest: If |
Yes I agree. Let’s just keep it uniform across all content types. |
I agree too. Error should be rendered uniformly. |
Below is a function I use for displaying exceptions and errors in my applications, It may be helpful (the PHP_EOL can be substituted with <br> where applicable): function getThrowableAsStr(\Throwable $e, string $eol=PHP_EOL): string {
$previous_throwable = $e;
$message = '';
do {
$message .= "Exception / Error Code: {$previous_throwable->getCode()}"
. $eol . "Exception / Error Class: " . get_class($previous_throwable)
. $eol . "File: {$previous_throwable->getFile()}"
. $eol . "Line: {$previous_throwable->getLine()}"
. $eol . "Message: {$previous_throwable->getMessage()}" . $eol
. $eol . "Trace: {$eol}{$previous_throwable->getTraceAsString()}{$eol}{$eol}";
$previous_throwable = $previous_throwable->getPrevious();
} while( $previous_throwable instanceof \Throwable );
return $message;
} |
The output of the error renderers can be controlled using
$displayErrorDetails
. But the slim error renderers would handle that differently.HtmlErrorRenderer
false
: Standard error message without any information about the exception.true
: Details like type, code, message, file, line and stack trace of the exception thrown. No information about previous exception(s).JsonErrorRenderer
false
: The error message of the exception thrown.true
: Details like type, code, message, file and line of the exception thrown as well as of the previous exception(s). But no stack trace for any exception(s).PlainTextErrorRenderer (See also #2744)
false
: Details like type, code, message, file, line and stack trace of the exception thrown.true
: Details like type, code, message, file, line and stack trace of the exception thrown as well as of all previous exception(s).XmlErrorRenderer
false
: The message of the exception thrown.true
: Additionally type, code, message, file and line of the exception thrown as well as of all previous exception(s). But no stack trace for any exception(s).What do you think the expected behaviour should be?
The text was updated successfully, but these errors were encountered: