better error handling
This commit is contained in:
parent
c63ade697a
commit
0477f14dde
16
bin/lessc
16
bin/lessc
@ -69,12 +69,16 @@ fs.stat(input, function (e, stats) {
|
||||
if (err) {
|
||||
less.writeError(err);
|
||||
} else {
|
||||
css = tree.toCSS({ compress: options.compress });
|
||||
if (output) {
|
||||
fd = fs.openSync(output, "w");
|
||||
fs.writeSync(fd, css, 0, "utf8");
|
||||
} else {
|
||||
sys.print(css);
|
||||
try {
|
||||
css = tree.toCSS({ compress: options.compress });
|
||||
if (output) {
|
||||
fd = fs.openSync(output, "w");
|
||||
fs.writeSync(fd, css, 0, "utf8");
|
||||
} else {
|
||||
sys.print(css);
|
||||
}
|
||||
} catch (e) {
|
||||
less.writeError(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -39,6 +39,10 @@ var less = {
|
||||
var extract = ctx.extract;
|
||||
var error = [];
|
||||
|
||||
if (ctx.stack) {
|
||||
return require('sys').puts(ctx.stack);
|
||||
}
|
||||
|
||||
if (typeof(extract[0]) === 'string') {
|
||||
error.push(stylize((ctx.line - 1) + ' ' + extract[0], 'grey'));
|
||||
}
|
||||
|
@ -236,6 +236,7 @@ less.Parser = function Parser(env) {
|
||||
name: "NameError",
|
||||
message: e.message,
|
||||
line: line,
|
||||
stack: e.stack,
|
||||
column: column,
|
||||
extract: [
|
||||
lines[line - 2],
|
||||
|
Loading…
Reference in New Issue
Block a user