Skip to content
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

Closed
adriansuter opened this issue Jun 28, 2019 · 5 comments
Closed
Labels

Comments

@adriansuter
Copy link
Contributor

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?

@l0gicgate
Copy link
Member

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?

@adriansuter
Copy link
Contributor Author

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 false, then the code and a standard error message. If true, then the details (type, code, message, file, line) of every exception and the full stack trace of the first exception.

@l0gicgate
Copy link
Member

Yes I agree. Let’s just keep it uniform across all content types.

@l0gicgate l0gicgate changed the title [4.x] Error renderers do not handle the displayErrorDetails uniformly 4.x - Error renderers do not handle the displayErrorDetails uniformly Aug 7, 2019
@shahariaazam
Copy link
Contributor

Yes I agree. Let’s just keep it uniform across all content types.

I agree too. Error should be rendered uniformly.

@rotexdegba
Copy link

rotexdegba commented Nov 29, 2019

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;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants