mirror of https://gitee.com/bigwinds/arangodb
it's dangerous to read from TryCatch if it has not been properly populated before (#4567)
This commit is contained in:
parent
3b6abfd4a8
commit
399d2e67f7
|
@ -82,7 +82,13 @@ Result executeTransaction(
|
|||
|
||||
if (tryCatch.HasCaught()) {
|
||||
//we have some javascript error that is not an arangoError
|
||||
std::string msg = *v8::String::Utf8Value(tryCatch.Message()->Get());
|
||||
std::string msg;
|
||||
if (!tryCatch.Message().IsEmpty()) {
|
||||
v8::String::Utf8Value m(tryCatch.Message()->Get());
|
||||
if (*m != nullptr) {
|
||||
msg = *m;
|
||||
}
|
||||
}
|
||||
rv.reset(TRI_ERROR_HTTP_SERVER_ERROR, msg);
|
||||
}
|
||||
|
||||
|
@ -287,12 +293,20 @@ Result executeTransactionJS(
|
|||
|
||||
action = v8::Local<v8::Function>::Cast(function);
|
||||
if (tryCatch.HasCaught()) {
|
||||
actionError += " - ";
|
||||
actionError += *v8::String::Utf8Value(tryCatch.Message()->Get());
|
||||
actionError += " - ";
|
||||
actionError += *v8::String::Utf8Value(tryCatch.StackTrace());
|
||||
if (!tryCatch.Message().IsEmpty()) {
|
||||
v8::String::Utf8Value tryCatchMessage(tryCatch.Message()->Get());
|
||||
if (*tryCatchMessage != nullptr) {
|
||||
actionError += " - ";
|
||||
actionError += *tryCatchMessage;
|
||||
}
|
||||
}
|
||||
v8::String::Utf8Value tryCatchStackTrace(tryCatch.StackTrace());
|
||||
if (*tryCatchStackTrace != nullptr) {
|
||||
actionError += " - ";
|
||||
actionError += *tryCatchStackTrace;
|
||||
}
|
||||
rv.reset(TRI_ERROR_BAD_PARAMETER, actionError);
|
||||
tryCatch.Reset(); //reset as we have transferd the error message into the Result
|
||||
tryCatch.Reset(); //reset as we have transferred the error message into the Result
|
||||
return rv;
|
||||
}
|
||||
action->SetName(TRI_V8_ASCII_STRING(isolate, "userTransactionSource"));
|
||||
|
|
|
@ -418,10 +418,12 @@ static void JS_Parse(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
|||
v8::Local<v8::Object> exceptionObj =
|
||||
tryCatch.Exception().As<v8::Object>();
|
||||
v8::Handle<v8::Message> message = tryCatch.Message();
|
||||
exceptionObj->Set(TRI_V8_ASCII_STRING(isolate, "lineNumber"),
|
||||
v8::Number::New(isolate, message->GetLineNumber()));
|
||||
exceptionObj->Set(TRI_V8_ASCII_STRING(isolate, "columnNumber"),
|
||||
v8::Number::New(isolate, message->GetStartColumn()));
|
||||
if (!message.IsEmpty()) {
|
||||
exceptionObj->Set(TRI_V8_ASCII_STRING(isolate, "lineNumber"),
|
||||
v8::Number::New(isolate, message->GetLineNumber()));
|
||||
exceptionObj->Set(TRI_V8_ASCII_STRING(isolate, "columnNumber"),
|
||||
v8::Number::New(isolate, message->GetStartColumn()));
|
||||
}
|
||||
exceptionObj->Set(TRI_V8_ASCII_STRING(isolate, "fileName"), filename->ToString());
|
||||
tryCatch.ReThrow();
|
||||
return;
|
||||
|
@ -489,10 +491,12 @@ static void JS_ParseFile(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
|||
v8::Local<v8::Object> exceptionObj =
|
||||
tryCatch.Exception().As<v8::Object>();
|
||||
v8::Handle<v8::Message> message = tryCatch.Message();
|
||||
exceptionObj->Set(TRI_V8_ASCII_STRING(isolate, "lineNumber"),
|
||||
v8::Number::New(isolate, message->GetLineNumber()));
|
||||
exceptionObj->Set(TRI_V8_ASCII_STRING(isolate, "columnNumber"),
|
||||
v8::Number::New(isolate, message->GetStartColumn()));
|
||||
if (!message.IsEmpty()) {
|
||||
exceptionObj->Set(TRI_V8_ASCII_STRING(isolate, "lineNumber"),
|
||||
v8::Number::New(isolate, message->GetLineNumber()));
|
||||
exceptionObj->Set(TRI_V8_ASCII_STRING(isolate, "columnNumber"),
|
||||
v8::Number::New(isolate, message->GetStartColumn()));
|
||||
}
|
||||
exceptionObj->Set(TRI_V8_ASCII_STRING(isolate, "fileName"), args[0]);
|
||||
tryCatch.ReThrow();
|
||||
return;
|
||||
|
@ -1046,10 +1050,12 @@ static void JS_Execute(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
|||
v8::Local<v8::Object> exceptionObj =
|
||||
tryCatch.Exception().As<v8::Object>();
|
||||
v8::Handle<v8::Message> message = tryCatch.Message();
|
||||
exceptionObj->Set(TRI_V8_ASCII_STRING(isolate, "lineNumber"),
|
||||
v8::Number::New(isolate, message->GetLineNumber()));
|
||||
exceptionObj->Set(TRI_V8_ASCII_STRING(isolate, "columnNumber"),
|
||||
v8::Number::New(isolate, message->GetStartColumn()));
|
||||
if (!message.IsEmpty()) {
|
||||
exceptionObj->Set(TRI_V8_ASCII_STRING(isolate, "lineNumber"),
|
||||
v8::Number::New(isolate, message->GetLineNumber()));
|
||||
exceptionObj->Set(TRI_V8_ASCII_STRING(isolate, "columnNumber"),
|
||||
v8::Number::New(isolate, message->GetStartColumn()));
|
||||
}
|
||||
exceptionObj->Set(TRI_V8_ASCII_STRING(isolate, "fileName"),
|
||||
filename->ToString());
|
||||
tryCatch.ReThrow();
|
||||
|
|
Loading…
Reference in New Issue