Skip to content

Commit db3166a

Browse files
committed
Prefer HTTP errors over parsing errors.
If there is an HTTP error, only use the body data for more specific error information if is was valid json and parsed, if it didn't parse just fall back to ignoring the response body and just remore the HTTP error.
1 parent 2faf6b1 commit db3166a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Source/Objects/GTLRService.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -806,10 +806,9 @@ - (GTLRServiceTicket *)fetchObjectWithURL:(NSURL *)targetURL
806806
[NSJSONSerialization JSONObjectWithData:(NSData * _Nonnull)data
807807
options:NSJSONReadingMutableContainers
808808
error:&parseError];
809-
if (parseError) {
810-
// We could not parse the JSON payload
811-
error = parseError;
812-
} else {
809+
// If the json parse worked, then extract potentially better
810+
// information.
811+
if (!parseError) {
813812
// HTTP Streaming defined by Google services is is an array
814813
// of requests and replies. This code never makes one of
815814
// these requests; but, some GET apis can actually be to

0 commit comments

Comments
 (0)