Skip to content

Commit

Permalink
Reland D38460203
Browse files Browse the repository at this point in the history
Summary:
D38460203 (facebook@e6ef083) was reverted because it broke OSS, the root cause is that OSS doesn't have MapBuffer module.

Fixed the issue in this diff by moving MapBuffer usage to fb internal class (FBReactModule) and will re-land.

Changelog:
[iOS][Changed] Replace Folly with MapBuffer for passing js error data

Reviewed By: sammy-SC

Differential Revision: D39210957

fbshipit-source-id: dda0e8c55dbd13bc96310e10a3b09ea53978e8bc
  • Loading branch information
luluwu2032 authored and OlimpiaZurek committed May 22, 2023
1 parent 8e8971d commit a8b7c81
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
5 changes: 4 additions & 1 deletion React/CoreModules/BUCK
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@fbsource//tools/build_defs/apple:flag_defs.bzl", "get_objc_arc_preprocessor_flags", "get_preprocessor_flags_for_build_mode")
load("@fbsource//tools/build_defs/oss:rn_defs.bzl", "rn_apple_library", "rn_extra_build_flags")
load("@fbsource//tools/build_defs/oss:rn_defs.bzl", "react_native_xplat_target", "rn_apple_library", "rn_extra_build_flags")
load(
"@fbsource//xplat/configurations/buck/apple/plugins/sad_xplat_hosted_configurations:react_module_registration.bzl",
"react_module_plugin_providers",
Expand Down Expand Up @@ -129,6 +129,9 @@ rn_apple_library(
],
reexport_all_header_dependencies = True,
visibility = ["PUBLIC"],
deps = [
react_native_xplat_target("react/renderer/mapbuffer:mapbufferApple"),
],
exported_deps = [
"//xplat/js/react-native-github:FBReactNativeSpecApple",
"//xplat/js/react-native-github:RCTLinkingApple",
Expand Down
5 changes: 4 additions & 1 deletion React/CoreModules/RCTExceptionsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ NS_ASSUME_NONNULL_BEGIN
- (void)reportFatalException:(nullable NSString *)message
stack:(nullable NSArray<NSDictionary *> *)stack
exceptionId:(double)exceptionId;
- (void)reportJsException:(NSString *)errorMap;
- (void)reportJsException:(nullable NSString *)message
stack:(nullable NSArray<NSDictionary *> *)stack
exceptionId:(double)exceptionId
isFatal:(bool)isFatal;

@property (nonatomic, weak) id<RCTExceptionsManagerDelegate> delegate;

Expand Down
16 changes: 4 additions & 12 deletions React/CoreModules/RCTExceptionsManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,11 @@ - (void)reportFatal:(NSString *)message
}
}

- (void)reportJsException:(NSString *)errorStr
- (void)reportJsException:(nullable NSString *)message
stack:(nullable NSArray<NSDictionary *> *)stack
exceptionId:(double)exceptionId
isFatal:(bool)isFatal
{
NSData *jsonData = [errorStr dataUsingEncoding:NSUTF8StringEncoding];
NSError *jsonError;
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:jsonData
options:NSJSONWritingPrettyPrinted
error:&jsonError];

NSString *message = [dict objectForKey:@"message"];
double exceptionId = [[dict objectForKey:@"id"] doubleValue];
NSArray *stack = [dict objectForKey:@"stack"];
BOOL isFatal = [[dict objectForKey:@"isFatal"] boolValue];

if (isFatal) {
[self reportFatalException:message stack:stack exceptionId:exceptionId];
} else {
Expand Down

0 comments on commit a8b7c81

Please sign in to comment.