mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
[Shared] Includes CodingPath in Source errors’ debug description (if available)
This commit is contained in:
@@ -122,7 +122,35 @@ final class FetchSourceOperation: ResultOperation<Source>
|
||||
decoder.managedObjectContext = childContext
|
||||
decoder.sourceURL = self.sourceURL
|
||||
|
||||
let source = try decoder.decode(Source.self, from: data)
|
||||
let source: Source
|
||||
|
||||
do
|
||||
{
|
||||
source = try decoder.decode(Source.self, from: data)
|
||||
}
|
||||
catch let error as DecodingError
|
||||
{
|
||||
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: " > ")
|
||||
|
||||
var userInfo = nsError.userInfo
|
||||
|
||||
if let debugDescription = nsError.localizedDebugDescription
|
||||
{
|
||||
let detailedDescription = debugDescription + "\n\n" + pathDescription
|
||||
userInfo[NSDebugDescriptionErrorKey] = detailedDescription
|
||||
}
|
||||
else
|
||||
{
|
||||
userInfo[NSDebugDescriptionErrorKey] = pathDescription
|
||||
}
|
||||
|
||||
throw NSError(domain: nsError.domain, code: nsError.code, userInfo: userInfo)
|
||||
}
|
||||
|
||||
let identifier = source.identifier
|
||||
|
||||
try self.verify(source, response: response)
|
||||
|
||||
Reference in New Issue
Block a user