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];
|
NSNumber* tagNum = [NSNumber numberWithLong:msgTag];
|
||||||
RCTResponseSenderBlock callback = [self getPendingSend:tagNum];
|
RCTResponseSenderBlock callback = [self getPendingSend:tagNum];
|
||||||
if (callback) {
|
if (callback) {
|
||||||
NSString* msg = [[error userInfo] valueForKey:@"NSLocalizedFailureReason"];
|
NSString *msg = error.localizedFailureReason ?: error.localizedDescription;
|
||||||
callback(@[msg]);
|
callback(@[msg ?: @"unkown error"]);
|
||||||
[self dropPendingSend:tagNum];
|
[self dropPendingSend:tagNum];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,8 @@ RCT_EXPORT_METHOD(bind:(nonnull NSNumber*)cId
|
||||||
NSError *error = nil;
|
NSError *error = nil;
|
||||||
if (![client bind:port address:address error:&error])
|
if (![client bind:port address:address error:&error])
|
||||||
{
|
{
|
||||||
NSString* msg = [[error userInfo] valueForKey:@"NSLocalizedFailureReason"];
|
NSString *msg = error.localizedFailureReason ?: error.localizedDescription;
|
||||||
callback(@[msg]);
|
callback(@[msg ?: @"unkown error when binding"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,8 +97,8 @@ RCT_EXPORT_METHOD(setBroadcast:(nonnull NSNumber*)cId
|
||||||
NSError *error = nil;
|
NSError *error = nil;
|
||||||
if (![client setBroadcast:flag error:&error])
|
if (![client setBroadcast:flag error:&error])
|
||||||
{
|
{
|
||||||
NSString* msg = [[error userInfo] valueForKey:@"NSLocalizedFailureReason"];
|
NSString *msg = error.localizedFailureReason ?: error.localizedDescription;
|
||||||
callback(@[msg]);
|
callback(@[msg ?: @"unkown error when setBroadcast"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
callback(@[[NSNull null]]);
|
callback(@[[NSNull null]]);
|
||||||
|
|
Loading…
Reference in New Issue