fix error output on unexpected errors

This commit is contained in:
Alexis Sellier
2011-12-16 19:06:24 +01:00
parent 3506838620
commit 96689e4f37

View File

@@ -43,6 +43,8 @@ var less = {
if (options.silent) { return }
if (ctx.stack) { return sys.error(stylize(ctx.stack, 'red')) }
if (!ctx.hasOwnProperty('index')) {
return sys.error(ctx.stack || ctx.message);
}
@@ -51,9 +53,11 @@ var less = {
error.push(stylize((ctx.line - 1) + ' ' + extract[0], 'grey'));
}
error.push(ctx.line + ' ' + extract[1].slice(0, ctx.column)
+ stylize(stylize(extract[1][ctx.column], 'bold')
+ extract[1].slice(ctx.column + 1), 'yellow'));
if (extract[1]) {
error.push(ctx.line + ' ' + extract[1].slice(0, ctx.column)
+ stylize(stylize(extract[1][ctx.column], 'bold')
+ extract[1].slice(ctx.column + 1), 'yellow'));
}
if (typeof(extract[2]) === 'string') {
error.push(stylize((ctx.line + 1) + ' ' + extract[2], 'grey'));
@@ -70,7 +74,6 @@ var less = {
sys.error(stylize('from ', 'red') + (ctx.filename || ''));
sys.error(stylize(ctx.callLine, 'grey') + ' ' + ctx.callExtract);
}
if (ctx.stack) { sys.error(stylize(ctx.stack, 'red')) }
}
};