Skip to content

Commit

Permalink
Implement RCTExceptionsManager.reportException on iOS
Browse files Browse the repository at this point in the history
Summary: Implements the new `reportException` method in the iOS version of `ExceptionsManager`.

Reviewed By: sammy-SC

Differential Revision: D17226365

fbshipit-source-id: baa81424399175eaf8fc0835d4df01897e7fa468
  • Loading branch information
motiz88 authored and facebook-github-bot committed Sep 6, 2019
1 parent 850a835 commit 9a57145
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions React/CoreModules/RCTExceptionsManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,34 @@ - (instancetype)initWithDelegate:(id<RCTExceptionsManagerDelegate>)delegate

RCT_EXPORT_METHOD(reportException:(JS::NativeExceptionsManager::ExceptionData &)data)
{
NSString *message = data.message();
double exceptionId = data.id_();

// Reserialize data.stack() into an array of untyped dictionaries.
// TODO: (moti) T53588496 Replace `(NSArray<NSDictionary *> *)stack` in
// reportFatalException etc with a typed interface.
NSMutableArray<NSDictionary *> *stackArray = [NSMutableArray<NSDictionary *> new];
for (auto frame: data.stack()) {
NSMutableDictionary * frameDict = [NSMutableDictionary new];
if (frame.column().hasValue()) {
frameDict[@"column"] = @(frame.column().value());
}
frameDict[@"file"] = frame.file();
if (frame.lineNumber().hasValue()) {
frameDict[@"lineNumber"] = @(frame.lineNumber().value());
}
frameDict[@"methodName"] = frame.methodName();
if (frame.collapse().hasValue()) {
frameDict[@"collapse"] = @(frame.collapse().value());
}
[stackArray addObject:frameDict];
}

if (data.isFatal()) {
[self reportFatalException:message stack:stackArray exceptionId:exceptionId];
} else {
[self reportSoftException:message stack:stackArray exceptionId:exceptionId];
}
}

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModuleWithJsInvoker:
Expand Down

0 comments on commit 9a57145

Please sign in to comment.