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

Handle fatal error on exception in __toString methods #673

Closed
antonsergeyev opened this issue Oct 25, 2015 · 0 comments
Closed

Handle fatal error on exception in __toString methods #673

antonsergeyev opened this issue Oct 25, 2015 · 0 comments
Labels

Comments

@antonsergeyev
Copy link

When a NormalizerFormatter tries to normalize an object that implements '__toString' method, and this method throws an exception (which is exceptionally bad, but still), it results in a messy fatal error, which is hard to debug. This is especially painful if happens in the process of logging another error or exception, so we end up not knowing what the original error was.

The solution, i think, is to simply call '$data->__toString()' instead of '(string) $data', which will correctly throw an exception instead of triggering fatal error.

antonsergeyev pushed a commit to antonsergeyev/monolog that referenced this issue Oct 25, 2015
Seldaek added a commit that referenced this issue Oct 29, 2015
#673 Fix fatal error while normalizing with __toString method
@Seldaek Seldaek closed this as completed Oct 29, 2015
@Seldaek Seldaek added the Bug label Oct 29, 2015
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

2 participants