mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-08 22:33:26 +01:00
[AltStoreCore]: cut out recursion due to customError inheritance in ALTLocalizedError for errorDescription field
This commit is contained in:
@@ -58,13 +58,8 @@ public extension ALTLocalizedError
|
|||||||
{
|
{
|
||||||
var errorCode: Int { self.code.rawValue }
|
var errorCode: Int { self.code.rawValue }
|
||||||
var errorDescription: String? {
|
var errorDescription: String? {
|
||||||
guard (self as NSError).localizedFailureReason == nil else {
|
// Use errorFailure directly without relying on bridging to NSError
|
||||||
// Error has localizedFailureReason, so return nil to construct localizedDescription from it + localizedFailureReason.
|
return self.errorFailure ?? self.failureReason
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise, return failureReason for localizedDescription to avoid system prepending "Operation Failed" message.
|
|
||||||
return self.failureReason
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var failureReason: String? {
|
var failureReason: String? {
|
||||||
@@ -72,15 +67,13 @@ public extension ALTLocalizedError
|
|||||||
}
|
}
|
||||||
|
|
||||||
var errorUserInfo: [String : Any] {
|
var errorUserInfo: [String : Any] {
|
||||||
var userInfo: [String: Any?] = [
|
let userInfo: [String: Any?] = [
|
||||||
NSLocalizedFailureErrorKey: self.errorFailure,
|
NSLocalizedFailureErrorKey: self.errorFailure,
|
||||||
ALTLocalizedTitleErrorKey: self.errorTitle,
|
ALTLocalizedTitleErrorKey: self.errorTitle,
|
||||||
ALTSourceFileErrorKey: self.sourceFile,
|
ALTSourceFileErrorKey: self.sourceFile,
|
||||||
ALTSourceLineErrorKey: self.sourceLine,
|
ALTSourceLineErrorKey: self.sourceLine,
|
||||||
]
|
]
|
||||||
|
|
||||||
userInfo.merge(self.userInfoValues) { (_, new) in new }
|
|
||||||
|
|
||||||
return userInfo.compactMapValues { $0 }
|
return userInfo.compactMapValues { $0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +100,7 @@ public extension ALTErrorCode
|
|||||||
{
|
{
|
||||||
static var errorDomain: String {
|
static var errorDomain: String {
|
||||||
let typeName = String(reflecting: Self.self) // "\(Self.self)" doesn't include module name, but String(reflecting:) does.
|
let typeName = String(reflecting: Self.self) // "\(Self.self)" doesn't include module name, but String(reflecting:) does.
|
||||||
let errorDomain = typeName.replacingOccurrences(of: "ErrorCode", with: "Error").replacingOccurrences(of: "Error.Code", with: "Error")
|
let errorDomain = typeName.replacingOccurrences(of: "ErrorCode", with: "Error")
|
||||||
return errorDomain
|
return errorDomain
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user