New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ios)(8_0_X): Instead of native exception send javascript exception #10883
fix(ios)(8_0_X): Instead of native exception send javascript exception #10883
Conversation
|
@@ -148,7 +148,13 @@ static JSValueRef CommonJSRequireCallback(JSContextRef jsContext, JSObjectRef js | |||
return [KrollObject toValue:ctx value:result]; | |||
} | |||
@catch (NSException *e) { | |||
return ThrowException(jsContext, [e reason], exception); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the ThrowException
method should be modified to report the exception. So all exceptions are logged.
JSValueRef ThrowException(JSContextRef contextRef, NSString *message, JSValueRef *exception)
{
JSGlobalContextRef globalContextRef = JSContextGetGlobalContext(contextRef);
JSContext *context = [JSContext contextWithJSGlobalContextRef:globalContextRef];
JSValue *errorValue = [JSValue valueWithNewErrorFromMessage:message inContext:context];
[[TiExceptionHandler defaultExceptionHandler] reportScriptError:[TiUtils scriptErrorValue: @{
@"stack": [errorValue valueForProperty:@"stack"],
@"message": message
}]];
JSStringRef jsString = JSStringCreateWithCFString((CFStringRef)message);
*exception = JSValueMakeString(contextRef, jsString);
JSStringRelease(jsString);
return JSValueMakeUndefined(contextRef);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, maybe you could just do this:
JSValueRef ThrowException(JSContextRef contextRef, NSString *message, JSValueRef *exception)
{
JSGlobalContextRef globalContextRef = JSContextGetGlobalContext(contextRef);
JSContext *context = [JSContext contextWithJSGlobalContextRef:globalContextRef];
*exception = [JSValue valueWithNewErrorFromMessage:message inContext:context];
return JSValueMakeUndefined(contextRef);
}
I haven't tested this, just an idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Good idea. Updated PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR: PASS
FR Passed. Javascript stake trace is now showing . |
https://jira.appcelerator.org/browse/TIMOB-27112