This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
syntax errors are printed to stderr, even when wrapped with try/catch #6920
Comments
This is how JavaScript works. You cannot catch a SyntaxError, as this is throw at the time the source is parsed. The try/catch only applies to runtime errors. |
a) the call to the require function happens at runtime, and b) the syntax error is caught, as you can see below:
You are probably thinking of examples like this:
But that's not what is happening. |
Just for the record: it's not a bug, pretty-printer just ate first "f" to fit the error in ~80 characters. |
ghost
assigned indutny
Feb 2, 2014
indutny
added a commit
to indutny/node
that referenced
this issue
Feb 5, 2014
Try embedding the ` ... ^` lines inside the `SyntaxError` (or any other native error) object before giving up and printing them to the stderr. fix nodejs#6920 fix nodejs#1310
Should be fixed by #7049 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I would expect no output to stderr when syntax or other exceptions are caught.
Also, not that the missing f before "function" is not a cut-n-paste error, I'm not sure why that is happening, possibly because of binary in my passwd file.
The text was updated successfully, but these errors were encountered: