From 96689e4f374e5bc69a95f9cb352b97697e0006c7 Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Fri, 16 Dec 2011 19:06:24 +0100 Subject: [PATCH] fix error output on unexpected errors --- lib/less/index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/less/index.js b/lib/less/index.js index 4b5d46d7..cac29679 100644 --- a/lib/less/index.js +++ b/lib/less/index.js @@ -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')) } } };