[AltBackup]: restore dropped changes

This commit is contained in:
Magesh K
2024-12-25 19:20:32 +05:30
parent e01e31f3d5
commit 2c29e3f902

View File

@@ -76,15 +76,27 @@ struct BackupError: ALTLocalizedError
let sourceFile: String let sourceFile: String
let sourceFileLine: Int let sourceFileLine: Int
var failure: String? var failure: String?
var errorTitle: String? var errorTitle: String?
var errorFailure: String? var errorFailure: String?
var failureReason: String? {
return self.code.errorFailureReason
}
// Conforming to the userInfo required by ALTLocalizedError var failureReason: String? {
switch self.code
{
case .invalidBundleID: return NSLocalizedString("The bundle identifier is invalid.", comment: "")
case .appGroupNotFound(let appGroup):
if let appGroup = appGroup
{
return String(format: NSLocalizedString("The app group “%@” could not be found.", comment: ""), appGroup)
}
else
{
return NSLocalizedString("The AltStore app group could not be found.", comment: "")
}
case .randomError: return NSLocalizedString("A random error occured.", comment: "")
}
}
var errorUserInfo: [String : Any] { var errorUserInfo: [String : Any] {
let userInfo: [String: Any?] = [NSLocalizedDescriptionKey: self.errorDescription, let userInfo: [String: Any?] = [NSLocalizedDescriptionKey: self.errorDescription,
NSLocalizedFailureReasonErrorKey: self.failureReason, NSLocalizedFailureReasonErrorKey: self.failureReason,
@@ -93,12 +105,12 @@ struct BackupError: ALTLocalizedError
ErrorUserInfoKey.sourceFileLine: self.sourceFileLine] ErrorUserInfoKey.sourceFileLine: self.sourceFileLine]
return userInfo.compactMapValues { $0 } return userInfo.compactMapValues { $0 }
} }
// Implement description for CustomStringConvertible // Implement description for CustomStringConvertible
var description: String { var description: String {
return "\(errorTitle ?? "Unknown Error"): \(failureReason ?? "No reason available")" return "\(errorTitle ?? "Unknown Error"): \(failureReason ?? "No reason available")"
} }
init(_ code: Code, description: String? = nil, file: String = #file, line: Int = #line) init(_ code: Code, description: String? = nil, file: String = #file, line: Int = #line)
{ {
self.code = code self.code = code