diff --git a/share/server/util.js b/share/server/util.js index 80abc3332c..6deadada15 100644 --- a/share/server/util.js +++ b/share/server/util.js @@ -120,6 +120,7 @@ var Couch = { }; function errstr(e) { + if (e == null) return String(e); // toSource() is a Spidermonkey "special" return (e.toSource ? e.toSource() : e.toString()); }; diff --git a/share/server/views.js b/share/server/views.js index d414436bd9..19a6a8928d 100644 --- a/share/server/views.js +++ b/share/server/views.js @@ -70,11 +70,11 @@ var Views = (function() { // JavaScript process. If you need to destroy the JavaScript // process, throw the error form matched by the block below. throw(["error", "map_runtime_error", "function raised 'fatal_error'"]); - } else if (err[0] == "fatal") { + } else if (err && err[0] == "fatal") { // Throwing errors of the form ["fatal","error_key","reason"] // will kill the OS process. This is not normally what you want. throw(err); - } else if (err.name == "InternalError") { + } else if (err && err.name == "InternalError") { throw(["fatal", err.name, err.message]); } var message = "function raised exception " + errstr(err);