[AltStoreCore] Includes more context when logging Patreon account errors

Includes full decoding path if possible.
This commit is contained in:
Riley Testut
2024-01-08 14:27:01 -06:00
committed by Magesh K
parent becc626027
commit 69a01a3262
2 changed files with 24 additions and 2 deletions

View File

@@ -180,6 +180,28 @@ public extension PatreonAPI
completion(.failure(PatreonAPIError(.notAuthenticated)))
}
case .failure(let error as DecodingError):
do
{
let nsError = error as NSError
guard let codingPath = nsError.userInfo[ALTNSCodingPathKey] as? [CodingKey] else { throw error }
let rawComponents = codingPath.map { $0.intValue?.description ?? $0.stringValue }
let pathDescription = rawComponents.joined(separator: " > ")
let localizedDescription = nsError.localizedDebugDescription ?? nsError.localizedDescription
let debugDescription = localizedDescription + " Path: " + pathDescription
var userInfo = nsError.userInfo
userInfo[NSDebugDescriptionErrorKey] = debugDescription
throw NSError(domain: nsError.domain, code: nsError.code, userInfo: userInfo)
}
catch let error as NSError
{
Logger.main.error("Failed to fetch Patreon account. \(error.localizedDebugDescription ?? error.localizedDescription, privacy: .public)")
completion(.failure(error))
}
case .failure(let error as NSError):
Logger.main.error("Failed to fetch Patreon account. \(error.localizedDebugDescription ?? error.localizedDescription, privacy: .public)")
completion(.failure(error))