mirror of
https://github.com/less/less.js.git
synced 2026-01-22 21:58:14 -05:00
improve error reporting, include filename
This commit is contained in:
@@ -39,13 +39,14 @@ if (! input) {
|
||||
|
||||
fs.stat(input, function (e, stats) {
|
||||
if (e) {
|
||||
sys.puts("lessc: " + e.message + ": '" + input + "'\n");
|
||||
sys.puts("lessc: " + e.message);
|
||||
process.exit(1);
|
||||
}
|
||||
fs.open(input, process.O_RDONLY, stats.mode, function (e, fd) {
|
||||
fs.read(fd, stats.size, 0, "utf8", function (e, data) {
|
||||
new(less.Parser)({
|
||||
paths: [path.dirname(input)]
|
||||
paths: [path.dirname(input)],
|
||||
filename: input
|
||||
}).parse(data, function (err, tree) {
|
||||
if (err) {
|
||||
less.writeError(err);
|
||||
|
||||
@@ -52,7 +52,8 @@ var less = {
|
||||
}
|
||||
error = error.join('\n') + '\033[0m\n';
|
||||
|
||||
require('sys').puts(stylize(ctx.message, 'red'), error);
|
||||
require('sys').puts(stylize(ctx.message + ' of ', 'red') +
|
||||
ctx.filename + ': ', error);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -91,9 +92,10 @@ less.Parser.importer = function (file, paths, callback) {
|
||||
if (e) sys.puts(e);
|
||||
|
||||
new(less.Parser)({
|
||||
paths: [path.dirname(pathname)]
|
||||
paths: [path.dirname(pathname)],
|
||||
filename: pathname
|
||||
}).parse(data, function (e, root) {
|
||||
if (e) sys.puts(e);
|
||||
if (e) less.writeError(e);
|
||||
callback(root);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -227,7 +227,8 @@ less.Parser = function Parser(env) {
|
||||
|
||||
error = {
|
||||
name: "ParseError",
|
||||
message: "Syntax Error on line " + line + ":",
|
||||
message: "Syntax Error on line " + line,
|
||||
filename: env.filename,
|
||||
line: line,
|
||||
column: column,
|
||||
extract: [
|
||||
|
||||
Reference in New Issue
Block a user