Skip to content

Commit

Permalink
fixed .compile() error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Nov 20, 2010
1 parent c7cd1ef commit 1a72378
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/jade.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

var Parser = require('./parser'),
Compiler = require('./compiler'),
sys = require('sys'),
fs = require('fs');

/**
Expand Down Expand Up @@ -142,7 +141,11 @@ function rethrow(err, str, filename, lineno){
: 0;
// Error context
var context = str.split('\n').slice(start, lineno).map(function(line, i){
return ' ' + (i + start + 1) + '. ' + sys.inspect(line);
return ' '
+ (i + start + 1)
+ ". '"
+ line.replace("'", "\\'")
+ "'";
}).join('\n');

// Alter exception message
Expand Down
4 changes: 3 additions & 1 deletion test/jade.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,8 @@ module.exports = {
} catch (e) {
err = e;
}
console.log(err.stack);
assert.equal(
"Jade:1\n 1. 'p= asdf'\n\nasdf is not defined",
err.message);
}
};

0 comments on commit 1a72378

Please sign in to comment.