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

Avoiding double-wrapping of Twig RuntimeError #1132

Merged
merged 1 commit into from
Sep 22, 2023

Conversation

weaverryan
Copy link
Member

Q A
Bug fix? yes
New feature? yes
Tickets None
License MIT

I had noticed that, when making a typo in my Twig file, the true error was hidden inside a nested exception.

Before (left top of page, right, further down the page)
Screenshot 2023-09-22 at 8 21 05 AMScreenshot 2023-09-22 at 8 21 16 AM

After

Screenshot 2023-09-22 at 8 18 24 AM

So, you see the exact error now. You lose that the error happened when rendering the InvoiceCreator component, but I think that's not important. And you can find that actually if you look up the stacktrace a bit.

Btw, the reason we want to throw a RuntimeError from Twig is if, when rendering, if you have an error in your PHP code (not template), it makes it look nicer. Without wrapping your PHP error in a RuntimeError, you get:

An exception has been thrown during the rendering of a template ("AHhhh").

After, it is:

Error rendering "Icon" component: AHhhh

So the RuntimeError is 👍 ... but we don't need to create a 2nd one if we already have one.

Cheers!

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

Successfully merging this pull request may close these issues.

1 participant