Browse files

improve syntax error messaging

  • Loading branch information...
1 parent c3250c8 commit c8a5ecadba50e45250fbb7bf289001faef9649b2 @smtlaissezfaire committed Feb 9, 2013
Showing with 14 additions and 1 deletion.
  1. +14 −1 lib/loop/eval.js
View
15 lib/loop/eval.js
@@ -83,7 +83,20 @@ var loopEval = function(syntaxTree) {
};
}
- throw new Error("unknown error - not sure what to do here. Bailing");
+ var errorMessage = "Parse error near: `" + firstToken.contents + "`";
+ if (firstToken.sourceInfo) {
+ errorMessage += [
+ ' ',
+ '-- line: ',
+ firstToken.sourceInfo.first_line,
+ " -- col: ",
+ firstToken.sourceInfo.first_column,
+ "-",
+ firstToken.sourceInfo.last_column
+ ].join('');
+ }
+
+ throw new Error(errorMessage);
case 'prop-access':
var key = contents.key;
var value = contents.value;

0 comments on commit c8a5eca

Please sign in to comment.