1
0
Fork 0

added better error reporting

This commit is contained in:
Frank Celler 2014-02-22 13:00:00 +01:00
parent 1bdcc145b4
commit a2fb92948e
1 changed files with 25 additions and 16 deletions

View File

@ -765,28 +765,37 @@ static v8::Handle<v8::Value> JS_Execute (v8::Arguments const& argv) {
} }
// execute script inside the context // execute script inside the context
v8::Handle<v8::Script> script = v8::Script::Compile(source->ToString(), filename); v8::Handle<v8::Script> script;
v8::Handle<v8::Value> result;
// compilation failed, print errors that happened during compilation {
if (script.IsEmpty()) { v8::TryCatch tryCatch;
if (useSandbox) {
context->DetachGlobal(); script = v8::Script::Compile(source->ToString(), filename);
context->Exit();
// compilation failed, print errors that happened during compilation
if (script.IsEmpty()) {
if (useSandbox) {
context->DetachGlobal();
context->Exit();
}
TRI_LogV8Exception(&tryCatch);
return scope.Close(v8::ThrowException(tryCatch.Exception()));
} }
return scope.Close(v8::Undefined()); // compilation succeeded, run the script
} result = script->Run();
// compilation succeeded, run the script if (result.IsEmpty()) {
v8::Handle<v8::Value> result = script->Run(); if (useSandbox) {
context->DetachGlobal();
context->Exit();
}
if (result.IsEmpty()) { TRI_LogV8Exception(&tryCatch);
if (useSandbox) { return scope.Close(v8::ThrowException(tryCatch.Exception()));
context->DetachGlobal();
context->Exit();
} }
return scope.Close(v8::Undefined());
} }
// copy result back into the sandbox // copy result back into the sandbox