fix error messages with no index

This commit is contained in:
cloudhead 2010-07-07 11:58:26 +02:00
parent 38272c7f85
commit 2afcdd7860
2 changed files with 4 additions and 4 deletions

View File

@ -311,9 +311,9 @@ less.Parser = function Parser(env) {
message: e.message, message: e.message,
filename: env.filename, filename: env.filename,
index: e.index, index: e.index,
line: line + 1, line: typeof(line) === 'number' ? line + 1 : null,
callLine: e.call && (getLine(e.call) + 1), callLine: e.call && (getLine(e.call) + 1),
callExtract: lines[getLine(e.call) - 1], callExtract: lines[getLine(e.call)],
stack: e.stack, stack: e.stack,
column: column, column: column,
extract: [ extract: [
@ -330,7 +330,7 @@ less.Parser = function Parser(env) {
} }
function getLine(index) { function getLine(index) {
return (input.slice(0, index).match(/\n/g) || "").length; return index ? (input.slice(0, index).match(/\n/g) || "").length : null;
} }
}; };
})(root.toCSS); })(root.toCSS);

View File

@ -19,7 +19,7 @@ tree.mixin.Call.prototype = {
rules, mixins[m].eval(this.arguments, env).rules); rules, mixins[m].eval(this.arguments, env).rules);
match = true; match = true;
} catch (e) { } catch (e) {
throw { message: e.message, index: e.index, call: this.index }; throw { message: e.message, index: e.index, stack: e.stack, call: this.index };
} }
} }
} }