Skip to content

Commit 2dbf0d4

Browse files
authored
App Crash on error body does not exists
Prevent crash if body does not exist on error
1 parent 6877fbd commit 2dbf0d4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/ios/CordovaHttpPlugin.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ - (void)handleError:(NSMutableDictionary*)dictionary withResponse:(NSHTTPURLResp
6969
[dictionary setValue:response.URL.absoluteString forKey:@"url"];
7070
[dictionary setObject:[NSNumber numberWithInt:(int)response.statusCode] forKey:@"status"];
7171
[dictionary setObject:[self copyHeaderFields:response.allHeaderFields] forKey:@"headers"];
72-
[dictionary setObject:error.userInfo[AFNetworkingOperationFailingURLResponseBodyKey] forKey:@"error"];
72+
if (error.userInfo[AFNetworkingOperationFailingURLResponseBodyKey]) {
73+
[dictionary setObject:error.userInfo[AFNetworkingOperationFailingURLResponseBodyKey] forKey:@"error"];
74+
}
7375
} else {
7476
[dictionary setObject:[self getStatusCode:error] forKey:@"status"];
7577
[dictionary setObject:[error localizedDescription] forKey:@"error"];

0 commit comments

Comments
 (0)