Browse files

fixed .compile() error handling

  • Loading branch information...
1 parent c7cd1ef commit 1a72378655b7ac2575accb83221a8ff42fdc9017 @tj tj committed Nov 19, 2010
Showing with 8 additions and 3 deletions.
  1. +5 −2 lib/jade.js
  2. +3 −1 test/jade.test.js
View
7 lib/jade.js
@@ -11,7 +11,6 @@
var Parser = require('./parser'),
Compiler = require('./compiler'),
- sys = require('sys'),
fs = require('fs');
/**
@@ -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
View
4 test/jade.test.js
@@ -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.