| 44 | } |
| 45 | |
| 46 | void NativeScriptException::ReThrowToV8() { |
| 47 | auto isolate = Isolate::GetCurrent(); |
| 48 | auto context = isolate->GetCurrentContext(); |
| 49 | Local<Value> errObj; |
| 50 | |
| 51 | if (m_javascriptException != nullptr) { |
| 52 | errObj = Local<Value>::New(isolate, *m_javascriptException); |
| 53 | if (errObj->IsObject()) { |
| 54 | if (!m_fullMessage.empty()) { |
| 55 | errObj.As<Object>()->Set( |
| 56 | context, ArgConverter::ConvertToV8String(isolate, "fullMessage"), |
| 57 | ArgConverter::ConvertToV8String(isolate, m_fullMessage)); |
| 58 | } else if (!m_message.empty()) { |
| 59 | errObj.As<Object>()->Set( |
| 60 | context, ArgConverter::ConvertToV8String(isolate, "fullMessage"), |
| 61 | ArgConverter::ConvertToV8String(isolate, m_message)); |
| 62 | } |
| 63 | } |
| 64 | } else if (!m_fullMessage.empty()) { |
| 65 | errObj = Exception::Error( |
| 66 | ArgConverter::ConvertToV8String(isolate, m_fullMessage)); |
| 67 | } else if (!m_message.empty()) { |
| 68 | errObj = |
| 69 | Exception::Error(ArgConverter::ConvertToV8String(isolate, m_message)); |
| 70 | } else if (!m_javaException.IsNull()) { |
| 71 | errObj = WrapJavaToJsException(); |
| 72 | } else { |
| 73 | errObj = Exception::Error(ArgConverter::ConvertToV8String( |
| 74 | isolate, "No javascript exception or message provided.")); |
| 75 | } |
| 76 | |
| 77 | isolate->ThrowException(errObj); |
| 78 | } |
| 79 | |
| 80 | void NativeScriptException::ReThrowToJava() { |
| 81 | jthrowable ex = nullptr; |