Fixes #17
It was crashing when trying to build a callback argument NSArray with a nil object. NSError's are not guaranteed to have a NSLocalizedFailureReason, so this case should be handled.
This commit is contained in:
parent
05b206deca
commit
41fc91c5cc
|
@ -126,8 +126,8 @@ NSString *const RCTUDPErrorDomain = @"RCTUDPErrorDomain";
|
|||
NSNumber* tagNum = [NSNumber numberWithLong:msgTag];
|
||||
RCTResponseSenderBlock callback = [self getPendingSend:tagNum];
|
||||
if (callback) {
|
||||
NSString* msg = [[error userInfo] valueForKey:@"NSLocalizedFailureReason"];
|
||||
callback(@[msg]);
|
||||
NSString *msg = error.localizedFailureReason ?: error.localizedDescription;
|
||||
callback(@[msg ?: @"unkown error"]);
|
||||
[self dropPendingSend:tagNum];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,8 +61,8 @@ RCT_EXPORT_METHOD(bind:(nonnull NSNumber*)cId
|
|||
NSError *error = nil;
|
||||
if (![client bind:port address:address error:&error])
|
||||
{
|
||||
NSString* msg = [[error userInfo] valueForKey:@"NSLocalizedFailureReason"];
|
||||
callback(@[msg]);
|
||||
NSString *msg = error.localizedFailureReason ?: error.localizedDescription;
|
||||
callback(@[msg ?: @"unkown error when binding"]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -97,8 +97,8 @@ RCT_EXPORT_METHOD(setBroadcast:(nonnull NSNumber*)cId
|
|||
NSError *error = nil;
|
||||
if (![client setBroadcast:flag error:&error])
|
||||
{
|
||||
NSString* msg = [[error userInfo] valueForKey:@"NSLocalizedFailureReason"];
|
||||
callback(@[msg]);
|
||||
NSString *msg = error.localizedFailureReason ?: error.localizedDescription;
|
||||
callback(@[msg ?: @"unkown error when setBroadcast"]);
|
||||
return;
|
||||
}
|
||||
callback(@[[NSNull null]]);
|
||||
|
|
Loading…
Reference in New Issue