passforios/passKit/Helpers/AppError.swift

50 lines
1.6 KiB
Swift
Raw Normal View History

//
// AppError.swift
// pass
//
// Created by Mingshen Sun on 30/4/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
import Foundation
public enum AppError: Error {
case RepositoryNotSetError
2019-01-06 20:10:47 +01:00
case RepositoryRemoteBranchNotFoundError(_: String)
case RepositoryBranchNotFound(_: String)
case KeyImportError
case PasswordDuplicatedError
case GitResetError
2017-04-30 18:29:47 -05:00
case PGPPublicKeyNotExistError
2017-10-15 21:37:00 +08:00
case WrongPasswordFilename
case DecryptionError
case UnknownError
2017-05-11 22:55:08 -07:00
}
extension AppError: LocalizedError {
public var errorDescription: String? {
switch self {
case .RepositoryNotSetError:
return "Git repository is not set."
2019-01-06 20:10:47 +01:00
case let .RepositoryRemoteBranchNotFoundError(remoteBranchName):
return "Cannot find remote branch 'origin/\(remoteBranchName)'."
case let .RepositoryBranchNotFound(branchName):
return "Branch with name '\(branchName)' not found in repository."
case .KeyImportError:
return "Cannot import the key."
case .PasswordDuplicatedError:
return "Cannot add the password: password duplicated."
case .GitResetError:
2017-05-04 20:17:59 +08:00
return "Cannot identify the latest synced commit."
2017-04-30 18:29:47 -05:00
case .PGPPublicKeyNotExistError:
return "PGP public key doesn't exist."
2017-10-15 21:37:00 +08:00
case .WrongPasswordFilename:
return "Cannot write to the password file."
case .DecryptionError:
return "Cannot decrypt password."
case .UnknownError:
return "Unknown error."
}
}
}