You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2013/08/02 22:08:34 UTC
[20/49] git commit: updated refs/heads/1867-feature-plugins to d269b53
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/1867-feature-plugins
Commit: aaa3921cb1cc1c96052630ac8a53ec2471e638d8
Parents: 54e0aa0
Author: Fedor Indutny <fe...@gmail.com>
Authored: Tue Jul 30 23:31:35 2013 +0400
Committer: Jan Lehnardt <ja...@apache.org>
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);
};