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,7 +765,13 @@ static v8::Handle<v8::Value> JS_Execute (v8::Arguments const& argv) {
}
// 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;
{
v8::TryCatch tryCatch;
script = v8::Script::Compile(source->ToString(), filename);
// compilation failed, print errors that happened during compilation
if (script.IsEmpty()) {
@ -774,11 +780,12 @@ static v8::Handle<v8::Value> JS_Execute (v8::Arguments const& argv) {
context->Exit();
}
return scope.Close(v8::Undefined());
TRI_LogV8Exception(&tryCatch);
return scope.Close(v8::ThrowException(tryCatch.Exception()));
}
// compilation succeeded, run the script
v8::Handle<v8::Value> result = script->Run();
result = script->Run();
if (result.IsEmpty()) {
if (useSandbox) {
@ -786,7 +793,9 @@ static v8::Handle<v8::Value> JS_Execute (v8::Arguments const& argv) {
context->Exit();
}
return scope.Close(v8::Undefined());
TRI_LogV8Exception(&tryCatch);
return scope.Close(v8::ThrowException(tryCatch.Exception()));
}
}
// copy result back into the sandbox