If the callback throws an error and imports are syncronous, let the error fall through to the calling scope.

This commit is contained in:
Luke Page
2013-03-18 10:01:18 +00:00
parent 420acfff73
commit dca9643a1a
2 changed files with 13 additions and 12 deletions

View File

@@ -10,13 +10,19 @@
tree.importVisitor.prototype = {
isReplacing: true,
run: function (root) {
// process the contents
this._visitor.visit(root);
var error;
try {
// process the contents
this._visitor.visit(root);
}
catch(e) {
error = e;
}
this.isFinished = true;
if (this.importCount === 0) {
this._finish();
this._finish(error);
}
},
visitImport: function (importNode, visitArgs) {
@@ -43,11 +49,11 @@
if (e && !e.filename) { e.index = importNode.index; e.filename = importNode.currentFileInfo.filename; }
if (imported && !importNode.options.multiple) { importNode.skip = imported; }
var subFinish = function() {
var subFinish = function(e) {
importVisitor.importCount--;
if (importVisitor.importCount === 0 && importVisitor.isFinished) {
importVisitor._finish();
importVisitor._finish(e);
}
};

View File

@@ -477,13 +477,8 @@ less.Parser = function Parser(env) {
};
if (env.processImports !== false) {
try {
new tree.importVisitor(this.imports, finish)
.run(root);
}
catch(e) {
error = e;
}
new tree.importVisitor(this.imports, finish)
.run(root);
} else {
finish();
}