Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D517D104A1 for ; Fri, 2 Aug 2013 13:59:19 +0000 (UTC) Received: (qmail 55352 invoked by uid 500); 2 Aug 2013 13:59:19 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 55276 invoked by uid 500); 2 Aug 2013 13:59:18 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 55264 invoked by uid 99); 2 Aug 2013 13:59:17 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Aug 2013 13:59:17 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 415028B73A1; Fri, 2 Aug 2013 13:59:17 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jan@apache.org To: commits@couchdb.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/master to aaa3921 Date: Fri, 2 Aug 2013 13:59:17 +0000 (UTC) Updated Branches: refs/heads/master 54e0aa0e9 -> aaa3921cb share/server: use toString instead of toSource Object.toSource is [non-standard][0] and missing in v8 and probably other javascript VMs. Its better to chop it off now that feel pain later if we'll decide to move to different javascript engine. [0]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/aaa3921c Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/aaa3921c Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/aaa3921c Branch: refs/heads/master Commit: aaa3921cb1cc1c96052630ac8a53ec2471e638d8 Parents: 54e0aa0 Author: Fedor Indutny Authored: Tue Jul 30 23:31:35 2013 +0400 Committer: Jan Lehnardt Committed: Fri Aug 2 15:59:05 2013 +0200 ---------------------------------------------------------------------- share/server/filter.js | 2 +- share/server/loop.js | 4 ++-- share/server/render.js | 10 ++++++---- share/server/util.js | 17 +++++++++++++---- share/server/views.js | 3 ++- 5 files changed, 24 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/aaa3921c/share/server/filter.js ---------------------------------------------------------------------- diff --git a/share/server/filter.js b/share/server/filter.js index 5d90f69..ad29266 100644 --- a/share/server/filter.js +++ b/share/server/filter.js @@ -29,7 +29,7 @@ var Filter = (function() { }, filter_view : function(fun, ddoc, args) { // recompile - var source = fun.toSource(); + var source = fun.toSource ? fun.toSource() : '(' + fun.toString() + ')'; fun = evalcx(source, filter_sandbox); var results = []; http://git-wip-us.apache.org/repos/asf/couchdb/blob/aaa3921c/share/server/loop.js ---------------------------------------------------------------------- diff --git a/share/server/loop.js b/share/server/loop.js index fcd016f..644d89b 100644 --- a/share/server/loop.js +++ b/share/server/loop.js @@ -44,7 +44,7 @@ function init_filter_sandbox() { } filter_sandbox.emit = Filter.emit; } catch(e) { - log(e.toSource()); + log(e.toSource ? e.toSource() : e.stack); } }; @@ -143,7 +143,7 @@ var Loop = function() { } else if (e.name) { respond(["error", e.name, e]); } else { - respond(["error","unnamed_error",e.toSource()]); + respond(["error","unnamed_error",e.toSource ? e.toSource() : e.stack]); } }; while (line = readline()) { http://git-wip-us.apache.org/repos/asf/couchdb/blob/aaa3921c/share/server/render.js ---------------------------------------------------------------------- diff --git a/share/server/render.js b/share/server/render.js index 9b3726c..49b0863 100644 --- a/share/server/render.js +++ b/share/server/render.js @@ -261,7 +261,7 @@ var Render = (function() { if (args[0] === null && isDocRequestPath(args[1])) { throw(["error", "not_found", "document not found"]); } else { - renderError(e, fun.toSource()); + renderError(e, fun.toString()); } } }; @@ -281,7 +281,7 @@ var Render = (function() { throw(["error", "render_error", "undefined response from update function"]); } } catch(e) { - renderError(e, fun.toSource()); + renderError(e, fun.toString()); } }; @@ -310,7 +310,7 @@ var Render = (function() { } blowChunks("end"); } catch(e) { - renderError(e, listFun.toSource()); + renderError(e, listFun.toString()); } }; @@ -318,7 +318,9 @@ var Render = (function() { if (e.error && e.reason || e[0] == "error" || e[0] == "fatal") { throw(e); } else { - var logMessage = "function raised error: "+e.toSource()+" \nstacktrace: "+e.stack; + var logMessage = "function raised error: " + + (e.toSource ? e.toSource() : e.toString()) + " \n" + + "stacktrace: " + e.stack; log(logMessage); throw(["error", "render_error", logMessage]); } http://git-wip-us.apache.org/repos/asf/couchdb/blob/aaa3921c/share/server/util.js ---------------------------------------------------------------------- diff --git a/share/server/util.js b/share/server/util.js index b7a62d8..6857132 100644 --- a/share/server/util.js +++ b/share/server/util.js @@ -94,7 +94,12 @@ var Couch = { return require(name, newModule); }]); } catch(e) { - throw ["error","compilation_error","Module require('"+name+"') raised error "+e.toSource()]; + throw [ + "error", + "compilation_error", + "Module require('" +name+ "') raised error " + + (e.toSource ? e.toSource() : e.stack) + ]; } ddoc._module_cache[newModule.id] = newModule.exports; } @@ -107,13 +112,17 @@ var Couch = { var functionObject = evaluate_function_source(source, eval); } } catch (err) { - throw(["error", "compilation_error", err.toSource() + " (" + source + ")"]); + throw([ + "error", + "compilation_error", + (err.toSource ? err.toSource() : err.stack) + " (" + source + ")" + ]); }; if (typeof(functionObject) == "function") { return functionObject; } else { throw(["error","compilation_error", - "Expression does not eval to a function. (" + source.toSource() + ")"]); + "Expression does not eval to a function. (" + source.toString() + ")"]); }; }, recursivelySeal : function(obj) { @@ -138,7 +147,7 @@ function respond(obj) { print(Couch.toJSON(obj)); } catch(e) { log("Error converting object to JSON: " + e.toString()); - log("error on obj: "+ obj.toSource()); + log("error on obj: "+ (obj.toSource ? obj.toSource() : obj.toString())); } }; http://git-wip-us.apache.org/repos/asf/couchdb/blob/aaa3921c/share/server/views.js ---------------------------------------------------------------------- diff --git a/share/server/views.js b/share/server/views.js index 38feb40..499a91b 100644 --- a/share/server/views.js +++ b/share/server/views.js @@ -63,7 +63,8 @@ var Views = (function() { // will kill the OS process. This is not normally what you want. throw(err); } - var message = "function raised exception " + err.toSource(); + var message = "function raised exception " + + (err.toSource ? err.toSource() : err.stack); if (doc) message += " with doc._id " + doc._id; log(message); };