improve coffee script error messages

This commit is contained in:
Fabian Jakobs 2011-05-16 18:03:00 +00:00
commit f4a9c1bc78
2 changed files with 15 additions and 0 deletions

View file

@ -225,6 +225,7 @@ define(function(require, exports, module) {
return 0;
}
if (match = HEREGEX.exec(this.chunk)) {
this.line += count(match[0], '\n');
return this.heregexToken(match);
}
prev = last(this.tokens);

View file

@ -55,6 +55,7 @@ oop.inherits(Worker, Mirror);
this.onUpdate = function() {
var value = this.doc.getValue();
try {
coffee.parse(value);
} catch(e) {
@ -66,6 +67,19 @@ oop.inherits(Worker, Mirror);
text: m[2],
type: "error"
});
return;
}
if (e instanceof SyntaxError) {
var m = e.message.match(/ on line (\d+)/);
if (m) {
this.sender.emit("error", {
row: parseInt(m[1]) - 1,
column: null,
text: e.message.replace(m[0], ""),
type: "error"
});
}
}
return;
}