diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-10-11 18:15:12 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-10-11 18:15:12 -0400 |
commit | 77fb45335a7563ceedf280d0c46642be53cb27fe (patch) | |
tree | 99a74f4e037cb9221121e3a1823ff8841012c9de /scripting/v8_utils.cpp | |
parent | 7363cf4d3c9d6f4243fbcd8deb57e09f7d19b5f0 (diff) | |
download | mongo-77fb45335a7563ceedf280d0c46642be53cb27fe.tar.gz |
v8 invoke works now
Diffstat (limited to 'scripting/v8_utils.cpp')
-rw-r--r-- | scripting/v8_utils.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/scripting/v8_utils.cpp b/scripting/v8_utils.cpp index 9b3dc4eda4f..bca67bf6a6c 100644 --- a/scripting/v8_utils.cpp +++ b/scripting/v8_utils.cpp @@ -36,6 +36,45 @@ namespace mongo { return s; } + std::string toSTLString( const v8::TryCatch * try_catch ){ + + stringstream ss; + + while ( try_catch ){ + + v8::String::Utf8Value exception(try_catch->Exception()); + Handle<v8::Message> message = try_catch->Message(); + + if (message.IsEmpty()) { + ss << *exception << endl; + } + else { + + v8::String::Utf8Value filename(message->GetScriptResourceName()); + int linenum = message->GetLineNumber(); + ss << *filename << ":" << linenum << " " << *exception << endl; + + v8::String::Utf8Value sourceline(message->GetSourceLine()); + ss << *sourceline << endl; + + int start = message->GetStartColumn(); + for (int i = 0; i < start; i++) + ss << " "; + + int end = message->GetEndColumn(); + for (int i = start; i < end; i++) + ss << "^"; + + ss << endl; + } + + try_catch = try_catch->next_; + } + + return ss.str(); + } + + std::ostream& operator<<( std::ostream &s, const Handle<v8::Value> & o ){ v8::String::Utf8Value str(o); s << *str; |