Add missing error messages and name them consistently
Since the AppError enum is suffixed with 'Error', the elements itself do not need this suffix, too.
This commit is contained in:
parent
08c91599b6
commit
38b44cedf8
3 changed files with 39 additions and 34 deletions
|
|
@ -6,23 +6,27 @@
|
|||
// Copyright © 2017 Bob Sun. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public enum AppError: Error {
|
||||
case RepositoryNotSetError
|
||||
case RepositoryRemoteBranchNotFoundError(_: String)
|
||||
case RepositoryNotSet
|
||||
case RepositoryRemoteBranchNotFound(_: String)
|
||||
case RepositoryBranchNotFound(_: String)
|
||||
case KeyImportError
|
||||
case PasswordDuplicatedError
|
||||
case GitResetError
|
||||
case PGPPublicKeyNotExistError
|
||||
case KeyImport
|
||||
case PasswordDuplicated
|
||||
case GitReset
|
||||
case PgpPublicKeyNotExist
|
||||
case WrongPasswordFilename
|
||||
case DecryptionError
|
||||
case UnknownError
|
||||
case Decryption
|
||||
case Unknown
|
||||
}
|
||||
|
||||
extension AppError: LocalizedError {
|
||||
public var errorDescription: String? {
|
||||
return String(describing: self).localize()
|
||||
let localizationKey = "\(String(describing: self).prefix(while: { $0 != "(" }))Error."
|
||||
switch self {
|
||||
case let .RepositoryRemoteBranchNotFound(name), let .RepositoryBranchNotFound(name):
|
||||
return localizationKey.localize(name)
|
||||
default:
|
||||
return localizationKey.localize()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue