Skip to content

Commit 718fb97

Browse files
committed
Merge pull request #46 from ParsePlatform/nlutsenko.underlyingError
Store original network error under NSUnderlyingError key.
2 parents e7741e2 + 2f01034 commit 718fb97

File tree

5 files changed

+5
-0
lines changed

5 files changed

+5
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ - (void)_taskDidFinish {
8282
errorDictionary[@"code"] = @(kPFErrorConnectionFailed);
8383
errorDictionary[@"error"] = [self.error localizedDescription];
8484
errorDictionary[@"originalError"] = self.error;
85+
errorDictionary[NSUnderlyingErrorKey] = self.error;
8586
errorDictionary[@"temporary"] = @(self.response.statusCode >= 500 || self.response.statusCode < 400);
8687
self.error = [PFErrorUtilities errorFromResult:errorDictionary];
8788
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ - (void)_taskDidFinish {
5454
errorDictionary[@"code"] = @(kPFErrorConnectionFailed);
5555
errorDictionary[@"error"] = [self.error localizedDescription];
5656
errorDictionary[@"originalError"] = self.error;
57+
errorDictionary[NSUnderlyingErrorKey] = self.error;
5758
errorDictionary[@"temporary"] = @(self.response.statusCode >= 500 || self.response.statusCode < 400);
5859
self.error = [PFErrorUtilities errorFromResult:errorDictionary];
5960
[super _taskDidFinish];

Tests/Unit/URLSessionDataTaskDelegateTests.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ - (void)testUnknownError {
130130
[delegate URLSession:mockedSession task:mockedTask didCompleteWithError:expectedError];
131131

132132
XCTAssertEqualObjects(delegate.resultTask.error.userInfo[@"originalError"], expectedError);
133+
XCTAssertEqualObjects(delegate.resultTask.error.userInfo[NSUnderlyingErrorKey], expectedError);
133134
}
134135

135136
- (void)testJSONError {

Tests/Unit/URLSessionTests.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ - (void)testPerformDataRequestError {
244244
[[session performDataURLRequestAsync:mockedURLRequest forCommand:mockedCommand cancellationToken:nil]
245245
continueWithBlock:^id(BFTask *task) {
246246
XCTAssertEqualObjects(expectedError, task.error.userInfo[@"originalError"]);
247+
XCTAssertEqualObjects(expectedError, task.error.userInfo[NSUnderlyingErrorKey]);
247248
[expectation fulfill];
248249
return nil;
249250
}];

Tests/Unit/URLSessionUploadTaskDelegateTests.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ - (void)testUnknownError {
205205
[delegate URLSession:mockedSession task:mockedTask didCompleteWithError:expectedError];
206206

207207
XCTAssertEqualObjects(delegate.resultTask.error.userInfo[@"originalError"], expectedError);
208+
XCTAssertEqualObjects(delegate.resultTask.error.userInfo[NSUnderlyingErrorKey], expectedError);
208209
}
209210

210211
- (void)testJSONError {

0 commit comments

Comments
 (0)