From f33fde4c065fbbe95c616e47ca87f890b74f49cd Mon Sep 17 00:00:00 2001 From: Mark Vayngrib Date: Mon, 12 Oct 2015 09:55:20 +0100 Subject: [PATCH] send strings instead of NSError over bridge, RCTBridge chokes sometimes on NSJSONSerialization of errors --- ios/UdpSocketClient.m | 3 ++- ios/UdpSockets.m | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ios/UdpSocketClient.m b/ios/UdpSocketClient.m index 19d86d9..4181eae 100644 --- a/ios/UdpSocketClient.m +++ b/ios/UdpSocketClient.m @@ -95,7 +95,8 @@ NSString *const RCTUDPErrorDomain = @"RCTUDPErrorDomain"; NSNumber* tagNum = [NSNumber numberWithLong:msgTag]; RCTResponseSenderBlock callback = [_pendingSends objectForKey:tagNum]; if (callback) { - callback(@[error]); + NSString* msg = [[error userInfo] valueForKey:@"NSLocalizedFailureReason"]; + callback(@[msg]); [_pendingSends removeObjectForKey:tagNum]; } } diff --git a/ios/UdpSockets.m b/ios/UdpSockets.m index 82f45d4..f0b0aac 100644 --- a/ios/UdpSockets.m +++ b/ios/UdpSockets.m @@ -50,7 +50,8 @@ RCT_EXPORT_METHOD(bind:(nonnull NSNumber*)cId NSError *error = nil; if (![client bind:port address:address error:&error]) { - callback(@[error]); + NSString* msg = [[error userInfo] valueForKey:@"NSLocalizedFailureReason"]; + callback(@[msg]); return; } @@ -91,7 +92,8 @@ RCT_EXPORT_METHOD(setBroadcast:(nonnull NSNumber*)cId NSError *error = nil; if (![client setBroadcast:flag error:&error]) { - callback(@[error]); + NSString* msg = [[error userInfo] valueForKey:@"NSLocalizedFailureReason"]; + callback(@[msg]); return; } callback(@[[NSNull null]]);