summaryrefslogtreecommitdiff
path: root/src/mongo/scripting/mozjs/implscope.cpp
diff options
context:
space:
mode:
authorJason Carey <jcarey@argv.me>2015-08-19 19:07:05 -0400
committerJason Carey <jcarey@argv.me>2015-08-21 14:03:31 -0400
commit96ac2fda3c2a080be037e9c043e4ee262ec5d850 (patch)
tree4b653184d3308cabdbdabeebda8369d69ac4a7c0 /src/mongo/scripting/mozjs/implscope.cpp
parentec738d5b38c6d30770e161706a4e71c2790c2a3a (diff)
downloadmongo-96ac2fda3c2a080be037e9c043e4ee262ec5d850.tar.gz
SERVER-20055 try harder in _checkErrorState in JS
_checkErrorState looks for an exception that's cleared the top of the js stack, but not a pending one. Check there too, to avoid stackless sad errors in a few more cases.
Diffstat (limited to 'src/mongo/scripting/mozjs/implscope.cpp')
-rw-r--r--src/mongo/scripting/mozjs/implscope.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/mongo/scripting/mozjs/implscope.cpp b/src/mongo/scripting/mozjs/implscope.cpp
index 4982ee4cc42..2f6cf57e2bd 100644
--- a/src/mongo/scripting/mozjs/implscope.cpp
+++ b/src/mongo/scripting/mozjs/implscope.cpp
@@ -711,7 +711,20 @@ bool MozJSImplScope::_checkErrorState(bool success, bool reportError, bool asser
return false;
if (_status.isOK()) {
- _status = Status(ErrorCodes::UnknownError, "Unknown Failure from JSInterpreter");
+ JS::RootedValue excn(_context);
+ if (JS_GetPendingException(_context, &excn) && excn.isObject()) {
+ str::stream ss;
+
+ JS::RootedValue stack(_context);
+
+ ObjectWrapper(_context, excn).getValue("stack", &stack);
+
+ ss << ValueWriter(_context, excn).toString() << " :\n"
+ << ValueWriter(_context, stack).toString();
+ _status = Status(ErrorCodes::JSInterpreterFailure, ss);
+ } else {
+ _status = Status(ErrorCodes::UnknownError, "Unknown Failure from JSInterpreter");
+ }
}
_error = _status.reason();