From 59382bc3ac4f784897a7db7dfa77edb0f07ee8ec Mon Sep 17 00:00:00 2001 From: Russell Hancox Date: Thu, 25 Jul 2024 10:48:16 -0400 Subject: [PATCH] sync: Handle missing error string for abnormal statuses (#1402) --- Source/santasyncservice/SNTSyncStage.mm | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Source/santasyncservice/SNTSyncStage.mm b/Source/santasyncservice/SNTSyncStage.mm index 0d897b7d1..fc32259e3 100644 --- a/Source/santasyncservice/SNTSyncStage.mm +++ b/Source/santasyncservice/SNTSyncStage.mm @@ -195,12 +195,9 @@ - (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; } @@ -208,7 +205,7 @@ - (NSData *)dataFromRequest:(NSURLRequest *)request if (error != NULL) { *error = [NSError errorWithDomain:@"com.google.santa.syncservice" code:code - userInfo:@{NSLocalizedDescriptionKey : errStr}]; + userInfo:@{NSLocalizedDescriptionKey : errStr ?: @""}]; } return nil; }