From 46fec78939b70a8fbe0d1af85a25cf50db32622e Mon Sep 17 00:00:00 2001 From: Christopher Lenz Date: Mon, 23 Jun 2008 20:16:47 +0000 Subject: 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 --- share/server/main.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'share/server') 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', '"' : '\\"', '\\': '\\\\'}; -- cgit v1.2.3