|
|
|
@ -116,6 +116,8 @@ public class Services { |
|
|
|
if let apiCallId, let type = (T.self as? any Storable.Type) { |
|
|
|
if let apiCallId, let type = (T.self as? any Storable.Type) { |
|
|
|
try Store.main.rescheduleApiCall(id: apiCallId, type: type) |
|
|
|
try Store.main.rescheduleApiCall(id: apiCallId, type: type) |
|
|
|
Store.main.logFailedAPICall(apiCallId, collectionName: type.resourceName(), error: errorString) |
|
|
|
Store.main.logFailedAPICall(apiCallId, collectionName: type.resourceName(), error: errorString) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Store.main.logFailedAPICall(request: request, error: errorString) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
throw ServiceError.responseError(response: errorString) |
|
|
|
throw ServiceError.responseError(response: errorString) |
|
|
|
@ -357,10 +359,14 @@ public class Services { |
|
|
|
fileprivate func errorMessageFromResponse(data: Data) -> String? { |
|
|
|
fileprivate func errorMessageFromResponse(data: Data) -> String? { |
|
|
|
do { |
|
|
|
do { |
|
|
|
if let jsonObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] { |
|
|
|
if let jsonObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] { |
|
|
|
if let stringsArray = jsonObject.values.first as? [String] { |
|
|
|
if let tuple = jsonObject.first { |
|
|
|
return stringsArray.first |
|
|
|
var error = "" |
|
|
|
} else if let string = jsonObject.values.first as? String { |
|
|
|
if let stringsArray = tuple.value as? [String], let first = stringsArray.first { |
|
|
|
return string |
|
|
|
error = first |
|
|
|
|
|
|
|
} else if let string = tuple.value as? String { |
|
|
|
|
|
|
|
error = string |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return "\(error) (\(tuple.key))" |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} catch { |
|
|
|
} catch { |
|
|
|
|