mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 12:45:37 +08:00
[React Native] Update native error callback handling
Summary: This introduces a new `RCTResponseErrorBlock` block type that allows a bridge module writer to call it with an `NSError` instance rather than a dictionary.
This commit is contained in:
@@ -231,12 +231,11 @@ BOOL RCTClassOverridesInstanceMethod(Class cls, SEL selector)
|
||||
NSDictionary *RCTMakeError(NSString *message, id toStringify, NSDictionary *extraData)
|
||||
{
|
||||
if (toStringify) {
|
||||
message = [NSString stringWithFormat:@"%@%@", message, toStringify];
|
||||
}
|
||||
NSMutableDictionary *error = [@{@"message": message} mutableCopy];
|
||||
if (extraData) {
|
||||
[error addEntriesFromDictionary:extraData];
|
||||
message = [message stringByAppendingString:[toStringify description]];
|
||||
}
|
||||
|
||||
NSMutableDictionary *error = [NSMutableDictionary dictionaryWithDictionary:extraData];
|
||||
error[@"message"] = message;
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user