send strings instead of NSError over bridge, RCTBridge chokes sometimes on NSJSONSerialization of errors

This commit is contained in:
Mark Vayngrib 2015-10-12 09:55:20 +01:00
parent 5812536d1f
commit f33fde4c06
2 changed files with 6 additions and 3 deletions

View File

@ -95,7 +95,8 @@ NSString *const RCTUDPErrorDomain = @"RCTUDPErrorDomain";
NSNumber* tagNum = [NSNumber numberWithLong:msgTag]; NSNumber* tagNum = [NSNumber numberWithLong:msgTag];
RCTResponseSenderBlock callback = [_pendingSends objectForKey:tagNum]; RCTResponseSenderBlock callback = [_pendingSends objectForKey:tagNum];
if (callback) { if (callback) {
callback(@[error]); NSString* msg = [[error userInfo] valueForKey:@"NSLocalizedFailureReason"];
callback(@[msg]);
[_pendingSends removeObjectForKey:tagNum]; [_pendingSends removeObjectForKey:tagNum];
} }
} }

View File

@ -50,7 +50,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])
{ {
callback(@[error]); NSString* msg = [[error userInfo] valueForKey:@"NSLocalizedFailureReason"];
callback(@[msg]);
return; return;
} }
@ -91,7 +92,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])
{ {
callback(@[error]); NSString* msg = [[error userInfo] valueForKey:@"NSLocalizedFailureReason"];
callback(@[msg]);
return; return;
} }
callback(@[[NSNull null]]); callback(@[[NSNull null]]);