More verbose and informative error messages, especially when dealing

with keyword values. Fixes #109
This commit is contained in:
Tom MacWright 2012-10-08 18:39:09 -04:00
parent 1d9b5d93ca
commit 45657268f9
3 changed files with 15 additions and 5 deletions

View File

@ -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',

View File

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

View File

@ -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.