|
42 | 42 | }
|
43 | 43 | }
|
44 | 44 |
|
45 |
| -std::string NativeScriptException::Description() const { |
46 |
| - std::stringstream ss; |
47 |
| - ss << "NativeScriptException: " << this->message_ << std::endl; |
48 |
| - ss << "StackTrace: " << this->stackTrace_ << std::endl; |
49 |
| - return ss.str(); |
50 |
| -} |
| 45 | +std::string NativeScriptException::Description() const { return this->fullMessage_; } |
51 | 46 |
|
52 | 47 | void NativeScriptException::OnUncaughtError(napi_env env, napi_value error) {
|
53 | 48 | NapiScope scope(env);
|
|
58 | 53 | fullMessageStream << napi_util::get_cxx_string(
|
59 | 54 | env, napi_util::get_property(env, error, "fullMessage"));
|
60 | 55 | } else {
|
| 56 | +#ifdef TARGET_ENGINE_V8 |
| 57 | + fullMessageStream << GetErrorStackTrace(env, error); |
| 58 | +#else |
61 | 59 | fullMessageStream << GetErrorMessage(env, error);
|
62 | 60 | fullMessageStream << "\n at \n" << GetErrorStackTrace(env, error);
|
| 61 | +#endif |
63 | 62 | }
|
64 | 63 |
|
65 | 64 | // TODO: discardUncaughtJsExceptions
|
|
80 | 79 |
|
81 | 80 | if (napi_util::is_of_type(env, result, napi_object)) {
|
82 | 81 | fullMessageStream << "\n\nError handler threw an error too:\n";
|
| 82 | +#ifdef TARGET_ENGINE_V8 |
| 83 | + fullMessageStream << GetErrorStackTrace(env, result); |
| 84 | +#else |
83 | 85 | fullMessageStream << GetErrorMessage(env, result);
|
84 | 86 | fullMessageStream << "\n at \n" << GetErrorStackTrace(env, result);
|
| 87 | +#endif |
85 | 88 | } else {
|
86 | 89 | fullMessageStream
|
87 | 90 | << "\n\nError handler threw an error too, but we couldn't get the error object";
|
|
91 | 94 |
|
92 | 95 | std::string fullMessage = fullMessageStream.str();
|
93 | 96 |
|
94 |
| - NSLog(@"NativeScriptException: %s", fullMessage.c_str()); |
| 97 | + NSLog(@"NativeScriptException::OnUncaughtError: %s", fullMessage.c_str()); |
95 | 98 |
|
96 |
| - NSException* objcException = [NSException exceptionWithName:@(fullMessage.c_str()) |
97 |
| - reason:nil |
| 99 | + NSException* objcException = [NSException exceptionWithName:@"NativeScriptException" |
| 100 | + reason:@(fullMessage.c_str()) |
98 | 101 | userInfo:@{@"sender" : @"onUncaughtError"}];
|
99 | 102 |
|
100 |
| - dispatch_async(dispatch_get_main_queue(), ^(void) { |
101 |
| - @throw objcException; |
102 |
| - }); |
| 103 | + // dispatch_async(dispatch_get_main_queue(), ^(void) { |
| 104 | + @throw objcException; |
| 105 | + // }); |
103 | 106 | }
|
104 | 107 |
|
105 | 108 | void NativeScriptException::ReThrowToJS(napi_env env) {
|
|
204 | 207 | return jsExceptionMessage;
|
205 | 208 | }
|
206 | 209 |
|
| 210 | + std::string stackTraceMessage = GetErrorStackTrace(env, error); |
| 211 | + |
207 | 212 | std::stringstream ss;
|
208 |
| - ss << jsExceptionMessage; |
209 | 213 |
|
210 |
| - std::string stackTraceMessage = GetErrorStackTrace(env, error); |
| 214 | +#ifdef TARGET_ENGINE_V8 |
| 215 | + ss << stackTraceMessage; |
| 216 | +#else |
| 217 | + ss << jsExceptionMessage; |
211 | 218 |
|
212 |
| - ss << std::endl << "StackTrace: " << std::endl << stackTraceMessage << std::endl; |
| 219 | + ss << std::endl << "StackTrace: " << std::endl << stackTraceMessage; |
| 220 | +#endif |
213 | 221 |
|
214 | 222 | std::string loggedMessage = ss.str();
|
215 | 223 |
|
216 |
| - PrintErrorMessage(loggedMessage); |
| 224 | + // PrintErrorMessage(loggedMessage); |
217 | 225 |
|
218 | 226 | return loggedMessage;
|
219 | 227 | }
|
|
0 commit comments