Fixes missing last Coding Path value for DecodingError.keyNotFound

This commit is contained in:
Riley Testut
2024-02-15 18:40:51 -06:00
committed by Magesh K
parent d2ed5bff57
commit c86e00413b

View File

@@ -136,7 +136,13 @@ final class FetchSourceOperation: ResultOperation<Source>
catch let error as DecodingError
{
let nsError = error as NSError
guard let codingPath = nsError.userInfo[ALTNSCodingPathKey] as? [CodingKey] else { throw error }
guard var codingPath = nsError.userInfo[ALTNSCodingPathKey] as? [CodingKey] else { throw error }
if case .keyNotFound(let key, _) = error
{
// Add missing key to error for better debugging.
codingPath.append(key)
}
let rawComponents = codingPath.map { $0.intValue?.description ?? $0.stringValue }
let pathDescription = rawComponents.joined(separator: " > ")