catch errors on css function calls

This commit is contained in:
cloudhead
2011-05-24 17:05:17 -04:00
parent 4417ef62c6
commit b043fd4507
2 changed files with 10 additions and 4 deletions

View File

@@ -3,9 +3,10 @@
//
// A function call node.
//
tree.Call = function (name, args) {
tree.Call = function (name, args, index) {
this.name = name;
this.args = args;
this.index = index;
};
tree.Call.prototype = {
//
@@ -24,7 +25,12 @@ tree.Call.prototype = {
var args = this.args.map(function (a) { return a.eval(env) });
if (this.name in tree.functions) { // 1.
return tree.functions[this.name].apply(tree.functions, args);
try {
return tree.functions[this.name].apply(tree.functions, args);
} catch (e) {
throw { message: "error evaluating function `" + this.name + "`",
index: this.index };
}
} else { // 2.
return new(tree.Anonymous)(this.name +
"(" + args.map(function (a) { return a.toCSS() }).join(', ') + ")");