mirror of
https://github.com/less/less.js.git
synced 2026-02-02 11:05:10 -05:00
improvements to error messages
This commit is contained in:
@@ -60,8 +60,9 @@ var less = {
|
||||
}
|
||||
error = error.join('\n') + '\033[0m\n';
|
||||
|
||||
message += stylize(ctx.message, 'red');
|
||||
ctx.filename && (message += stylize(' in ', 'red') + ctx.filename);
|
||||
message += stylize(ctx.type + 'Error: ' + ctx.message, 'red');
|
||||
ctx.filename && (message += stylize(' in ', 'red') + ctx.filename +
|
||||
stylize(':' + ctx.line + ':' + ctx.column, 'grey'));
|
||||
|
||||
sys.error(message, error);
|
||||
|
||||
|
||||
@@ -367,7 +367,7 @@ less.Parser = function Parser(env) {
|
||||
for (var n = i, column = -1; n >= 0 && input.charAt(n) !== '\n'; n--) { column++ }
|
||||
|
||||
error = {
|
||||
name: "ParseError",
|
||||
type: "Parse",
|
||||
message: "Syntax Error on line " + line,
|
||||
index: i,
|
||||
filename: env.filename,
|
||||
|
||||
@@ -27,7 +27,8 @@ tree.mixin.Call.prototype = {
|
||||
if (match) {
|
||||
return rules;
|
||||
} else {
|
||||
throw { message: 'No matching definition was found for `' +
|
||||
throw { type: 'Runtime',
|
||||
message: 'No matching definition was found for `' +
|
||||
this.selector.toCSS().trim() + '(' +
|
||||
this.arguments.map(function (a) {
|
||||
return a.toCSS();
|
||||
@@ -36,7 +37,8 @@ tree.mixin.Call.prototype = {
|
||||
}
|
||||
}
|
||||
}
|
||||
throw { message: this.selector.toCSS().trim() + " is undefined",
|
||||
throw { type: 'Name',
|
||||
message: this.selector.toCSS().trim() + " is undefined",
|
||||
index: this.index };
|
||||
}
|
||||
};
|
||||
@@ -71,7 +73,7 @@ tree.mixin.Definition.prototype = {
|
||||
if (val = (args && args[i]) || this.params[i].value) {
|
||||
frame.rules.unshift(new(tree.Rule)(this.params[i].name, val.eval(env)));
|
||||
} else {
|
||||
throw { message: "wrong number of arguments for " + this.name +
|
||||
throw { type: 'Runtime', message: "wrong number of arguments for " + this.name +
|
||||
' (' + args.length + ' for ' + this.arity + ')' };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user