ejs: Is it possible to get the line number in the ejs errors?
I originally posted this question on StackOverflow. This is the original post:
(Suppose) I have a huge ejs file containing JavaScript snippets. When I compile it, I get the following error:
SyntaxError: Unexpected token ) in mytemplate.ejs while compiling ejs
While it’s obvious there is a syntax error in my template, I can’t know where the error is.
I have full access to the error object so, I was thinking if somewhere the error contains the line with the problem (in a similar way like the JavaScript engines tell you that there is a problem on a specific line).
I tried to access the err.stack
field, but it only shows me the error origin (which comes from the ejs library), so that’s not really helpful.
Is there a way to know where the syntax error is in the ejs file?
I’m using the ejs
package.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 36 (22 by maintainers)
Commits related to this issue
- Fixed issue https://github.com/mde/ejs/issues/119 — committed to dgofman/ejs by dgofman 8 years ago
- Fixed issue https://github.com/mde/ejs/issues/119 — committed to BananaAcid/ejs-with-exts by dgofman 8 years ago
- updated with Fixed issue mde#119 — committed to BananaAcid/ejs-with-exts by BananaAcid 8 years ago
- Merge pull request #129 from dgofman/master Fixed issue https://github.com/mde/ejs/issues/119 — committed to mde/ejs by mde 8 years ago
- Merge branch 'master' into feature/multi-views * master: Fix more mistakes Fix Mistakes Add warning for ejs.render(dataAndOptions) Document JSDoc scripts in the README Clarify jsdocs for fi... — committed to MarcelloDiSimone/ejs by deleted user 8 years ago
@ciroreed You solution shouldn’t work. @IonicaBizau I fixed issue in code related in template. But your in compilation error (Syntax Error) handling outside template try/catch block. When I will get a time I will deep look how to fix it. Currently I don’t have experiences writing invalid JavaScript code 😃