Skip to content
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

Merged

Conversation

vijaysingh-axway
Copy link
Contributor

@vijaysingh-axway vijaysingh-axway commented May 11, 2019

@build build added this to the 8.0.1 milestone May 11, 2019
@build build requested a review from a team May 11, 2019 00:40
@build
Copy link
Contributor

build commented May 11, 2019

Messages
📖

💾 Here's the generated SDK zipfile.

📖

✅ All tests are passing
Nice one! All 3025 tests are passing.

Generated by 🚫 dangerJS against 24f9d40

@@ -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);
Copy link
Contributor

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);
}

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@sgtcoolguy sgtcoolguy modified the milestones: 8.0.1, 8.0.2 May 17, 2019
@vijaysingh-axway vijaysingh-axway changed the title fix(iOS)(8_0_X): Instead of native exception send javascript exception fix(ios)(8_0_X): Instead of native exception send javascript exception May 29, 2019
Copy link
Contributor

@garymathews garymathews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR: PASS

@keerthi1032
Copy link
Contributor

FR Passed. Javascript stake trace is now showing .
Test Environment:
Operating System
Name = Mac OS X
Version = 10.13.6
Architecture = 64bit
Node.js
Node.js Version = 8.9.1
npm Version = 5.5.1
Titanium CLI
CLI Version = 5.1.1
Titanium SDK
SDK Version = local sdk 8.1.0.v20190531095040 and local sdk 8.0.2.v20190531094628
Studio = 5.1.2.201903111843
CLI= 7.0.11
Device =iPhone 6s iOS 12
Simulator =iPhone 6 iOS 11

@keerthi1032 keerthi1032 merged commit 71f89e9 into tidev:8_0_X May 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants