Use env.error instead of throw.
This commit is contained in:
parent
fbf9b22931
commit
2e70fa9e10
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user