passforios/passKit/Helpers/AppError.swift
Danny Moesch 38b44cedf8 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.
2019-01-20 21:04:04 -08:00

32 lines
871 B
Swift

//
// AppError.swift
// pass
//
// Created by Mingshen Sun on 30/4/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
public enum AppError: Error {
case RepositoryNotSet
case RepositoryRemoteBranchNotFound(_: String)
case RepositoryBranchNotFound(_: String)
case KeyImport
case PasswordDuplicated
case GitReset
case PgpPublicKeyNotExist
case WrongPasswordFilename
case Decryption
case Unknown
}
extension AppError: LocalizedError {
public var errorDescription: String? {
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()
}
}
}