Skip to content

Commit f216769

Browse files
committed
Fix potential crash when network error doesn't have a description.
1 parent c9e1fc8 commit f216769

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Parse/Internal/Commands/CommandRunner/URLSession/Session/TaskDelegate/PFURLSessionJSONDataTaskDelegate.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,15 @@ - (void)_taskDidFinish {
5151
if (self.error) {
5252
NSMutableDictionary *errorDictionary = [NSMutableDictionary dictionary];
5353
errorDictionary[@"code"] = @(kPFErrorConnectionFailed);
54-
errorDictionary[@"error"] = [self.error localizedDescription];
5554
errorDictionary[@"originalError"] = self.error;
5655
errorDictionary[NSUnderlyingErrorKey] = self.error;
5756
errorDictionary[@"temporary"] = @(self.response.statusCode >= 500 || self.response.statusCode < 400);
57+
58+
NSString *description = [self.error localizedDescription] ?: [self.error localizedFailureReason];
59+
if (description) {
60+
errorDictionary[@"error"] = description;
61+
}
62+
5863
self.error = [PFErrorUtilities errorFromResult:errorDictionary];
5964
[super _taskDidFinish];
6065
return;

0 commit comments

Comments
 (0)