|
3 | 3 | #include "V8GlobalHelpers.h"
|
4 | 4 | #include "NativeScriptAssert.h"
|
5 | 5 | #include "V8StringConstants.h"
|
| 6 | +#include "include/v8.h" |
6 | 7 | #include <sstream>
|
7 | 8 |
|
8 | 9 | using namespace std;
|
@@ -43,6 +44,9 @@ void NativeScriptException::ReThrowToV8()
|
43 | 44 | if (m_javascriptException != nullptr)
|
44 | 45 | {
|
45 | 46 | errObj = Local<Value>::New(isolate, *m_javascriptException);
|
| 47 | + if(errObj->IsObject() && !m_message.empty()) { |
| 48 | + errObj.As<Object>()->Set(ConvertToV8String("fullMessage"), ConvertToV8String(m_message)); |
| 49 | + } |
46 | 50 | }
|
47 | 51 | else if (!m_message.empty())
|
48 | 52 | {
|
@@ -151,30 +155,19 @@ void NativeScriptException::Init(ObjectManager *objectManager)
|
151 | 155 | // ON V8 UNCAUGHT EXCEPTION
|
152 | 156 | void NativeScriptException::OnUncaughtError(Local<Message> message, Local<Value> error)
|
153 | 157 | {
|
154 |
| - auto errorMessage = PrintErrorMessage(message, error); |
155 |
| - |
156 |
| - Isolate *isolate = Isolate::GetCurrent(); |
157 |
| - HandleScope scope(isolate); |
| 158 | + string errorMessage; |
| 159 | + auto v8FullMessage = ConvertToV8String("fullMessage"); |
158 | 160 |
|
159 |
| - Local<Object> errorObject; |
160 |
| - if (error->IsObject()) |
161 |
| - { |
162 |
| - errorObject = error.As<Object>(); |
163 |
| - errorObject->Set(ConvertToV8String("message"), ConvertToV8String(errorMessage)); |
164 |
| - } |
165 |
| - else |
166 |
| - { |
167 |
| - errorObject = Exception::Error(ConvertToV8String(errorMessage)).As<Object>(); |
| 161 | + if(error->IsObject() && error.As<Object>()->Has(v8FullMessage)) { |
| 162 | + errorMessage = ConvertToString(error.As<Object>()->Get(v8FullMessage).As<String>()); |
168 | 163 | }
|
169 | 164 |
|
170 |
| - CallJsFuncWithErr(errorObject); |
| 165 | + if(errorMessage.size() == 0) { |
| 166 | + errorMessage = GetErrorMessage(message, error); |
| 167 | + } |
171 | 168 |
|
172 |
| - // check whether the developer marked the error as "Caught" |
173 |
| - // As per discussion, it is safer to ALWAYS kill the application due to uncaught error(s) |
174 |
| - // TODO: We may think for some per-thread specific behavior and allow execution to continue for background thread exceptions |
175 |
| -// if(!returnValue.IsEmpty() && (returnValue->IsBoolean() || returnValue->IsBooleanObject())){ |
176 |
| -// handled = returnValue->BooleanValue(); |
177 |
| -// } |
| 169 | + NativeScriptException e(errorMessage); |
| 170 | + e.ReThrowToJava(); |
178 | 171 | }
|
179 | 172 |
|
180 | 173 | void NativeScriptException::CallJsFuncWithErr(Local<Value> errObj)
|
|
0 commit comments