mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 04:35:36 +08:00
[ReactNative] Move module info from bridge to RCTModuleData
Summary: @public The info about bridge modules (such as id, name, queue, methods...) was spread across arrays & dictionaries on the bridge, move it into a specific class. It also removes a lot of information that was statically cached, and now have the same lifecycle of the bridge. Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own files, for organization sake. NOTE: This diff seems huge, but most of it was just moving code :) Test Plan: Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything looks fine.
This commit is contained in:
@@ -285,3 +285,24 @@ id RCTNilIfNull(id value)
|
||||
{
|
||||
return value == (id)kCFNull ? nil : value;
|
||||
}
|
||||
|
||||
// TODO: Can we just replace RCTMakeError with this function instead?
|
||||
NSDictionary *RCTJSErrorFromNSError(NSError *error)
|
||||
{
|
||||
NSString *errorMessage;
|
||||
NSArray *stackTrace = [NSThread callStackSymbols];
|
||||
NSMutableDictionary *errorInfo =
|
||||
[NSMutableDictionary dictionaryWithObject:stackTrace forKey:@"nativeStackIOS"];
|
||||
|
||||
if (error) {
|
||||
errorMessage = error.localizedDescription ?: @"Unknown error from a native module";
|
||||
errorInfo[@"domain"] = error.domain ?: RCTErrorDomain;
|
||||
errorInfo[@"code"] = @(error.code);
|
||||
} else {
|
||||
errorMessage = @"Unknown error from a native module";
|
||||
errorInfo[@"domain"] = RCTErrorDomain;
|
||||
errorInfo[@"code"] = @-1;
|
||||
}
|
||||
|
||||
return RCTMakeError(errorMessage, nil, errorInfo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user