Skip to content

Commit

Permalink
Better reporting for js syntax errors
Browse files Browse the repository at this point in the history
Big hack, but if we could catch the syntax errors,
we could apply a real lineno to the stack trace.

At least this exposes the contents of the line
  • Loading branch information
tj committed Jul 3, 2010
1 parent cd67780 commit 0fa6466
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/users.jade
Expand Up @@ -7,4 +7,4 @@ users
- user.roles.forEach(function(role){
role= role
- })
- })
- })
10 changes: 8 additions & 2 deletions lib/jade.js
Expand Up @@ -679,8 +679,14 @@ exports.render = function(str, options){
}

// Generate function
var fn = Function('locals, attrs, escape, _', 'with (locals) {' + js + '}');

try {
var fn = Function('locals, attrs, escape, _', 'with (locals) {' + js + '}');
} catch (err) {
// TODO: re-catch and apply real lineno
process.compile(js, filename || 'Jade');
return;
}

try {
var _ = { lineno: 1 };
return fn.call(options.scope,
Expand Down

0 comments on commit 0fa6466

Please sign in to comment.