Browse files

stringify data in exceptions

  • Loading branch information...
1 parent 56e3070 commit 73f981962088834ad077da0278c95a3f16686bf8 @amccollum committed Oct 4, 2011
Showing with 12 additions and 12 deletions.
  1. +5 −5 lib/wings.js
  2. +1 −1 package.json
  3. +6 −6 src/wings/wings.coffee
View
10 lib/wings.js
@@ -51,7 +51,7 @@
value = data[name];
if (!(value != null)) {
if (op === ':') {
- throw "Invalid section: " + data + ": " + name + ": " + value;
+ throw "Invalid section: " + (JSON.stringify(data)) + ": " + name;
} else {
return "";
}
@@ -78,7 +78,7 @@
value = data[name];
if (!(value != null)) {
if (op === '!') {
- throw "Invalid inverted section: " + data + ": " + name + ": " + value;
+ throw "Invalid inverted section: " + (JSON.stringify(data)) + ": " + name;
} else {
return "";
}
@@ -93,7 +93,7 @@
case '@':
link = links ? links[name] : null;
if (!(link != null)) {
- throw "Invalid link: " + links + ": " + name + ": " + link;
+ throw "Invalid link: " + (JSON.stringify(links)) + ": " + name;
} else if (typeof link === 'function') {
link = link.call(data);
}
@@ -110,7 +110,7 @@
}
}
if (!(value != null)) {
- throw "Invalid value: " + data + ": " + name + ": " + value;
+ throw "Invalid value: " + (JSON.stringify(data)) + ": " + name;
} else if (typeof value === 'function') {
value = value.call(data);
}
@@ -120,7 +120,7 @@
return escapeXML(value);
}
default:
- throw "Invalid op: " + op;
+ throw "Invalid section op: " + op;
}
});
};
View
2 package.json
@@ -1,6 +1,6 @@
{
"name": "wings",
- "version": "0.5.1",
+ "version": "0.5.2",
"description": "Templating library that works on the server and client closely modeled on Mustache",
"keywords": ["ender", "template", "mustache", "html"],
"author": "Andrew McCollum <amccollum@gmail.com>",
View
12 src/wings/wings.coffee
@@ -22,7 +22,7 @@
else return s
parse_re = ///
- \s* \{([?:!]+) \s* ([^}]*?) \s* \} ([\S\s]+?) \s* \{/ \s* \2 \s*\} | # sections
+ \s* \{([?:!]+) \s* ([^}]*?) \s* \} ([\S\s]+?) \s* \{/ \s* \2 \s*\} | # sections
\{(\#) \s* [\S\s]+? \s* \#\} | # comments
\{([@&]?) \s* ([^}]*?) \s* \} # tags
///mg
@@ -45,7 +45,7 @@
value = data[name]
if not value?
if op == ':'
- throw "Invalid section: #{data}: #{name}: #{value}"
+ throw "Invalid section: #{JSON.stringify(data)}: #{name}"
else
return ""
@@ -73,7 +73,7 @@
value = data[name]
if not value?
if op == '!'
- throw "Invalid inverted section: #{data}: #{name}: #{value}"
+ throw "Invalid inverted section: #{JSON.stringify(data)}: #{name}"
else
return ""
@@ -90,7 +90,7 @@
link = if links then links[name] else null
if not link?
- throw "Invalid link: #{links}: #{name}: #{link}"
+ throw "Invalid link: #{JSON.stringify(links)}: #{name}"
else if typeof link == 'function'
link = link.call(data)
@@ -107,14 +107,14 @@
value = null
if not value?
- throw "Invalid value: #{data}: #{name}: #{value}"
+ throw "Invalid value: #{JSON.stringify(data)}: #{name}"
else if typeof value == 'function'
value = value.call(data)
return (if op == '&' then value else escapeXML(value))
else
- throw "Invalid op: #{op}"
+ throw "Invalid section op: #{op}"
)(exports ? (@['wings'] = {}))

0 comments on commit 73f9819

Please sign in to comment.