Skip to content

Commit

Permalink
sync: Handle missing error string for abnormal statuses (#1402)
Browse files Browse the repository at this point in the history
  • Loading branch information
russellhancox authored Jul 25, 2024
1 parent 0725fcc commit 59382bc
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions Source/santasyncservice/SNTSyncStage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,17 @@ - (NSData *)dataFromRequest:(NSURLRequest *)request

// If the final attempt resulted in an error, log the error and return nil.
if (response.statusCode != 200) {
long code;
NSString *errStr;
if (response.statusCode > 0) {
code = response.statusCode;
errStr = [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode];
} else {
long code = response.statusCode;
NSString *errStr = [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode];
if (requestError.localizedDescription) {
code = (long)requestError.code;
errStr = requestError.localizedDescription;
}
LOGE(@"HTTP Response: %ld %@", code, errStr);
if (error != NULL) {
*error = [NSError errorWithDomain:@"com.google.santa.syncservice"
code:code
userInfo:@{NSLocalizedDescriptionKey : errStr}];
userInfo:@{NSLocalizedDescriptionKey : errStr ?: @""}];
}
return nil;
}
Expand Down

0 comments on commit 59382bc

Please sign in to comment.