fix error message when no filename, also try to print stack
This commit is contained in:
parent
ffc7c4c094
commit
58c457f1d3
@ -24,6 +24,9 @@ args = args.filter(function (arg) {
|
||||
case 'version':
|
||||
sys.puts("lessc " + less.version.join('.') + " (LESS Compiler) [JavaScript]");
|
||||
process.exit(0);
|
||||
case 'verbose':
|
||||
options.verbose = true;
|
||||
break;
|
||||
case 'h':
|
||||
case 'help':
|
||||
sys.puts("usage: lessc source [destination]");
|
||||
|
@ -36,11 +36,12 @@ var less = {
|
||||
}
|
||||
},
|
||||
writeError: function (ctx) {
|
||||
var message = "";
|
||||
var extract = ctx.extract;
|
||||
var error = [];
|
||||
|
||||
if (ctx.stack) {
|
||||
return require('sys').error(ctx.stack);
|
||||
if (!ctx.index && ctx.stack) {
|
||||
return sys.error(ctx.stack);
|
||||
}
|
||||
|
||||
if (typeof(extract[0]) === 'string') {
|
||||
@ -56,8 +57,12 @@ var less = {
|
||||
}
|
||||
error = error.join('\n') + '\033[0m\n';
|
||||
|
||||
require('sys').error(stylize(ctx.message + ' of ', 'red') +
|
||||
ctx.filename + ': ', error);
|
||||
message += stylize(ctx.message, 'red');
|
||||
ctx.filename && (message += stylize(' in ', 'red') + ctx.filename);
|
||||
|
||||
sys.error(message, error);
|
||||
|
||||
if (ctx.verbose && ctx.stack) { sys.error(stylize(ctx.stack, 'red')) }
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -238,9 +238,11 @@ less.Parser = function Parser(env) {
|
||||
throw {
|
||||
name: "NameError",
|
||||
message: e.message,
|
||||
filename: env.filename,
|
||||
line: line,
|
||||
stack: e.stack,
|
||||
column: column,
|
||||
verbose: env.verbose,
|
||||
extract: [
|
||||
lines[line - 2],
|
||||
lines[line - 1],
|
||||
|
Loading…
Reference in New Issue
Block a user