-
Notifications
You must be signed in to change notification settings - Fork 15
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
Improve transform error handling with compiled function annotations #88
Conversation
Hi and sorry for the late response! For example, if I have this code: <h1>
{{ foo() }}
</h1> The error that I see is this:
And this is useful, because I can see the line of the vento file where the error has originated. But if I have a parse error like this (Note the missing final parenthesis): <h1>
{{ foo( }}
</h1> The error I see is this:
And the origin of the error is not clear, I can't see the filename or the line number of the vento code. As an idea, instead of throwing directly the error of the compiled code, it can wrapped with a vento error, passing the meriyah error as the What do you think? can you try these changes? |
Shoot, I thought I included the original code. Will incorporate that and try out some of your suggestions. Thanks for taking a look! |
Just checked on my end with the changes I initially comitted and was able to confirm that errors were getting thrown with original code, strange you weren't seeing that. Anyway, just pushed new changes. Quick summary:
I mentioned before; not sure if moving all error-making things to an // environment.ts
import { RuntimeError } from './errors.ts`
class Environment {
// ...
createError =
} Maybe |
I just checked it and the new errors are great, much more clear!
I tend to avoid regex if a simple My only doubt is whether the other caused errors should be added to the error chain. The top error shows the messages of the nested errors nicely formatted, for example:
The other |
The stack might be more useful if meriyah wasn't distributed as a minified library. Since it is, I agree with you—it's better left up to the consuming packages to handle errors more gracefully. The just pushed changes should address this and also unify other errors thrown in Couple questions:
|
Hi!
Yes, it makes sense.
Do you mean a new property in the error with the vento code? If this helps to Eleventy integration, yes, why not. |
@noelforte Is this PR is ready to be merged? |
@oscarotero Sure go ahead. I started working on an |
…g to `deno.land` URL instead
additionally, create an error class for transform errors that can carry `pos` back to environment.ts to pass along to `createError`.
…and refactor options interface to extend the default ErrorOptions
… in other areas of module
…tances prefixed with `[meriyah]` to indicate source of error
great. thank you! |
Here's an attempt to further improve #85. I'm not super happy with the implementation, since it feels like transform errors and template errors should be handled seperately. I didn't want to start refactoring everything so I tried to make these edits as reviewable as possible and keep the discussion going.
My reasoning for adding an annotated message logging the line of the compiled template function was to explain the errors that
meriyah
might throw and make it clear that the error is happening on a compiled function, not a user-authored one. To deal with these errors originating from the Eleventy integration, I also plan to add a message to my plugin reminding users to check for undeclared shortcodes and filters since those will cause errors whenmeriyah
goes to parse/transform.Happy to edit/revise further if there's a cleaner way of tracking these errors!
Also included in this pull:
dnt
and JSR, for whatever reason,dnt
was complaining that@std/[email protected]
wasn't able to be resolved. Reverting to thedeno.land
url fixes this for now.