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)
|
||||
|
||||
@@ -19,6 +19,8 @@ extern NSErrorUserInfoKey const ALTDeviceNameErrorKey;
|
||||
extern NSErrorUserInfoKey const ALTOperatingSystemNameErrorKey;
|
||||
extern NSErrorUserInfoKey const ALTOperatingSystemVersionErrorKey;
|
||||
|
||||
extern NSErrorUserInfoKey const ALTNSCodingPathKey;
|
||||
|
||||
typedef NS_ERROR_ENUM(AltServerErrorDomain, ALTServerError)
|
||||
{
|
||||
ALTServerErrorUnderlyingError = -1,
|
||||
|
||||
@@ -37,6 +37,8 @@ NSErrorUserInfoKey const ALTDeviceNameErrorKey = @"deviceName";
|
||||
NSErrorUserInfoKey const ALTOperatingSystemNameErrorKey = @"ALTOperatingSystemName";
|
||||
NSErrorUserInfoKey const ALTOperatingSystemVersionErrorKey = @"ALTOperatingSystemVersion";
|
||||
|
||||
NSErrorUserInfoKey const ALTNSCodingPathKey = @"NSCodingPath";
|
||||
|
||||
@implementation NSError (ALTServerError)
|
||||
|
||||
+ (void)load
|
||||
|
||||
Reference in New Issue
Block a user