summaryrefslogtreecommitdiff
path: root/share/server
diff options
context:
space:
mode:
authorChristopher Lenz <cmlenz@apache.org>2008-06-23 20:16:47 +0000
committerChristopher Lenz <cmlenz@apache.org>2008-06-23 20:16:47 +0000
commit46fec78939b70a8fbe0d1af85a25cf50db32622e (patch)
tree6b3e75a6939b4835723e7ef6ab24663dcd9d1bcf /share/server
parentd825d64a38dd7dbc17a8301258bdc36ad87797b3 (diff)
Improve error handling for undefined values emitted by map functions. Closes COUCHDB-83.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@670732 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/server')
-rw-r--r--share/server/main.js8
1 files changed, 3 insertions, 5 deletions
diff --git a/share/server/main.js b/share/server/main.js
index 3c228779..02241649 100644
--- a/share/server/main.js
+++ b/share/server/main.js
@@ -80,9 +80,7 @@ while (cmd = eval(readline())) {
map_results = [];
try {
funs[i](doc);
- buf.push(map_results.filter(function(pair) {
- return pair[0] !== undefined && pair[1] !== undefined;
- }));
+ buf.push(toJSON(map_results));
} catch (err) {
if (err == "fatal_error") {
// Only if it's a "fatal_error" do we exit. What's a fatal error?
@@ -150,7 +148,7 @@ while (cmd = eval(readline())) {
quit();
}
} catch (exception) {
- print(toJSON(exception.toString()));
+ print(toJSON(exception));
}
}
@@ -181,7 +179,7 @@ function recursivelySeal(obj) {
function toJSON(val) {
if (typeof(val) == "undefined") {
- throw {error:"bad_value", reason:"Cannot encode 'undefined' value as JSON"};
+ throw "Cannot encode 'undefined' value as JSON";
}
var subs = {'\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f',
'\r': '\\r', '"' : '\\"', '\\': '\\\\'};