| 476 | } |
| 477 | |
| 478 | void Runtime::PassExceptionToJsNative(JNIEnv* env, jobject obj, |
| 479 | jthrowable exception, jstring message, |
| 480 | jstring fullStackTrace, |
| 481 | jstring jsStackTrace, |
| 482 | jboolean isDiscarded) { |
| 483 | auto isolate = m_isolate; |
| 484 | |
| 485 | string errMsg = ArgConverter::jstringToString(message); |
| 486 | |
| 487 | auto errObj = |
| 488 | Exception::Error(ArgConverter::ConvertToV8String(isolate, errMsg)) |
| 489 | .As<Object>(); |
| 490 | |
| 491 | // create a new native exception js object |
| 492 | jint javaObjectID = m_objectManager->GetOrCreateObjectId((jobject)exception); |
| 493 | auto nativeExceptionObject = |
| 494 | m_objectManager->GetJsObjectByJavaObject(javaObjectID); |
| 495 | |
| 496 | if (nativeExceptionObject.IsEmpty()) { |
| 497 | string className = m_objectManager->GetClassName((jobject)exception); |
| 498 | // create proxy object that wraps the java err |
| 499 | nativeExceptionObject = |
| 500 | m_objectManager->CreateJSWrapper(javaObjectID, className); |
| 501 | if (nativeExceptionObject.IsEmpty()) { |
| 502 | nativeExceptionObject = Object::New(isolate); |
| 503 | } |
| 504 | } |
| 505 | |
| 506 | // create a JS error object |
| 507 | auto context = isolate->GetCurrentContext(); |
| 508 | errObj->Set(context, V8StringConstants::GetNativeException(isolate), |
| 509 | nativeExceptionObject); |
| 510 | errObj->Set(context, V8StringConstants::GetStackTrace(isolate), |
| 511 | ArgConverter::jstringToV8String(isolate, fullStackTrace)); |
| 512 | if (jsStackTrace != NULL) { |
| 513 | errObj->Set(context, V8StringConstants::GetStack(isolate), |
| 514 | ArgConverter::jstringToV8String(isolate, jsStackTrace)); |
| 515 | } |
| 516 | |
| 517 | // pass err to JS |
| 518 | NativeScriptException::CallJsFuncWithErr(errObj, isDiscarded); |
| 519 | } |
| 520 | |
| 521 | void Runtime::PassUncaughtExceptionFromWorkerToMainHandler( |
| 522 | Local<v8::String> message, Local<v8::String> stackTrace, |
no test coverage detected