|
37 | 37 | bool success = global->Get(context, tns::ToV8String(isolate, cbName)).ToLocal(&handler);
|
38 | 38 |
|
39 | 39 | std::string stackTrace = GetErrorStackTrace(isolate, message->GetStackTrace());
|
| 40 | + std::string fullMessage; |
| 41 | + |
| 42 | + auto errObject = error.As<Object>(); |
| 43 | + auto fullMessageString = tns::ToV8String(isolate, "fullMessage"); |
| 44 | + if(errObject->HasOwnProperty(context, fullMessageString).ToChecked()) { |
| 45 | + // check if we have a "fullMessage" on the error, and log that instead - since it includes more info about the exception. |
| 46 | + auto fullMessage_ = errObject->Get(context, fullMessageString).ToLocalChecked(); |
| 47 | + fullMessage = tns::ToString(isolate, fullMessage_); |
| 48 | + } else { |
| 49 | + Local<v8::String> messageV8String = message->Get(); |
| 50 | + std::string messageString = tns::ToString(isolate, messageV8String); |
| 51 | + fullMessage = messageString + "\n at \n" + stackTrace; |
| 52 | + } |
| 53 | + |
40 | 54 | if (success && handler->IsFunction()) {
|
41 | 55 | if (error->IsObject()) {
|
42 | 56 | tns::Assert(error.As<Object>()->Set(context, tns::ToV8String(isolate, "stackTrace"), tns::ToV8String(isolate, stackTrace)).FromMaybe(false), isolate);
|
|
56 | 70 | }
|
57 | 71 |
|
58 | 72 | if (!isDiscarded) {
|
59 |
| - Local<v8::String> messageV8String = message->Get(); |
60 |
| - std::string messageString = tns::ToString(isolate, messageV8String); |
61 |
| - NSString* name = [NSString stringWithFormat:@"NativeScript encountered a fatal error: %s\n at \n%s", messageString.c_str(), stackTrace.c_str()]; |
| 73 | + NSString* name = [NSString stringWithFormat:@"NativeScript encountered a fatal error:\n\n%s", fullMessage.c_str()]; |
62 | 74 | // we throw the exception on main thread
|
63 | 75 | // otherwise it seems that when getting NSException info from NSSetUncaughtExceptionHandler
|
64 | 76 | // we are missing almost all data. No explanation for why yet
|
|
0 commit comments