Use env.error instead of throw.

This commit is contained in:
Will White 2011-09-02 16:18:37 -04:00
parent fbf9b22931
commit 2e70fa9e10
3 changed files with 14 additions and 13 deletions

View File

@ -189,10 +189,10 @@ function getMapProperties(m, rulesets, env) {
for (var i = 0; i < r.rules.length; i++) {
var key = r.rules[i].name;
if (!(key in symbolizers)) {
throw {
env.error({
message: 'Rule ' + key + ' not allowed for Map.',
index: r.rules[i].index
};
});
}
rules[key] = r.rules[i].eval(env).toXML(env);
}

View File

@ -9,6 +9,7 @@ tree.Filter = function Filter(key, op, val, index) {
}
this.op = op;
this.index = index;
if (val.is) {
this.val = val.value;
@ -17,15 +18,6 @@ tree.Filter = function Filter(key, op, val, index) {
this.val = val;
}
if (op !== '=' && op !== '!=') {
this.val = 1 * this.val;
if (isNaN(this.val)) {
throw {
message: 'Cannot use operator "' + op + '" with value ' + val,
index: index
};
}
}
this.id = this.key + this.op + this.val;
};
@ -41,6 +33,15 @@ var opXML = {
};
tree.Filter.prototype.toXML = function(env) {
if (this.op !== '=' && this.op !== '!=') {
this.val = 1 * this.val;
if (isNaN(this.val)) {
env.error({
message: 'Cannot use operator "' + this.op + '" with value ' + this.val,
index: this.index
});
}
}
if (this.val.eval) this._val = this.val.eval(env);
if (this.key.eval) this._key = this.key.eval(env);
if (this._key) var key = this._key.toString(false);

View File

@ -22,11 +22,11 @@ tree.Operation.prototype.eval = function(env) {
if (this.op === '*' || this.op === '+') {
temp = b, b = a, a = temp;
} else {
throw {
env.error({
name: "OperationError",
message: "Can't substract or divide a color from a number",
index: this.index
};
});
}
}