-
Notifications
You must be signed in to change notification settings - Fork 187
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
Adds SyntaxError
#540
Adds SyntaxError
#540
Conversation
* Subclass of `Error` with additional information | ||
* about location of incorrect markup. | ||
*/ | ||
class SyntaxError extends Error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you double check what this transpiles to? I vaguely recall issues with subclassing Error in IE9 and IE10. It may not matter as much here though since this code is primarily ran in node-land...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea this does not compile in Babel 6 correctly.
* about location of incorrect markup. | ||
*/ | ||
class SyntaxError extends Error { | ||
location: AST.SourceLocation; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we generally call this loc
everywhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loc
is kind of ambiguous tbh, I'd prefer location
(also the property name that broccoli-builder
expects is location
not loc
). If you feel strongly that we should stay consistent here, I can rename.
@@ -149,7 +148,7 @@ export abstract class HandlebarsNodeVisitors extends Parser { | |||
break; | |||
|
|||
default: | |||
throw new Error(`Using a Handlebars comment when in the \`${tokenizer.state}\` state is not supported: "${comment.value}" on line ${loc.start.line}:${loc.start.column}`); | |||
throw new SyntaxError(`Using a Handlebars comment when in the \`${tokenizer.state}\` state is not supported: "${comment.value}" on line ${loc.start.line}:${loc.start.column}`, rawComment.loc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we should still include the loc info inside the message now that we thread loc through the rest of the system?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should; it makes the error message more useful and it would be weird to make it less useful imo
Overall, looks really good. Just had a few questions/clarifications.... |
This is going to be awesome! 👍 |
Adds a subclass of
Error
with additionallocation
property. This helps to deliver error information tobroccoli-builder
and improve error reporting as described here.I believe this closes #348