More verbose and informative error messages, especially when dealing

with keyword values. Fixes #109
master-mapnik-geometry-type
Tom MacWright 12 years ago
parent 1d9b5d93ca
commit 45657268f9

@ -58,13 +58,20 @@ tree.Rule.prototype.toXML = function(env, content, sep, format) {
filename: this.filename
});
} else {
var typename;
if (tree.Reference.selector(this.name).validate) {
typename = tree.Reference.selector(this.name).validate;
} else if (typeof tree.Reference.selector(this.name).type === 'object') {
typename = 'keyword (options: ' + tree.Reference.selector(this.name).type.join(', ') + ')';
} else {
typename = tree.Reference.selector(this.name).type;
}
return env.error({
message: 'Invalid value for ' +
this.name +
', a valid ' +
(tree.Reference.selector(this.name).validate ||
tree.Reference.selector(this.name).type) +
', the type ' + typename +
' is expected. ' + this.value +
' (of type ' + this.value.value[0].is + ') ' +
' was given.',
index: this.index,
type: 'syntax',

@ -1,3 +1,5 @@
#world[zoom=5] {
polygon-opacity: #f00;
text-face-name: 2;
line-rasterizer: 'full';
text-name: 'foo';
}

@ -1 +1,2 @@
invalid_value.mss:2:2 Invalid value for polygon-opacity, a valid float is expected. #ff0000 was given.
invalid_value.mss:2:2 Invalid value for text-face-name, the type font is expected. 2 (of type float) was given.
invalid_value.mss:3:2 Invalid value for line-rasterizer, the type keyword (options: full, fast) is expected. full (of type string) was given.

Loading…
Cancel
Save