passforios/passKit/Helpers/AppError.swift
Bob Sun 2abbceb2e9
Set name and url in Password non-optional
Name and url in Password class shouldn't be optional because we store
them in core data as non-optional. This change also help us to avoid
man unneccessary unwrap.
2018-11-10 22:38:12 -08:00

49 lines
1.4 KiB
Swift

//
// 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
case RepositoryRemoteMasterNotFoundError
case KeyImportError
case PasswordDuplicatedError
case GitResetError
case PGPPublicKeyNotExistError
case WrongPasswordFilename
case YamlLoadError
case DecryptionError
case UnknownError
}
extension AppError: LocalizedError {
public var errorDescription: String? {
switch self {
case .RepositoryNotSetError:
return "Git repository is not set."
case .RepositoryRemoteMasterNotFoundError:
return "Cannot find remote branch origin/master."
case .KeyImportError:
return "Cannot import the key."
case .PasswordDuplicatedError:
return "Cannot add the password: password duplicated."
case .GitResetError:
return "Cannot identify the latest synced commit."
case .PGPPublicKeyNotExistError:
return "PGP public key doesn't exist."
case .WrongPasswordFilename:
return "Cannot write to the password file."
case .YamlLoadError:
return "Cannot be parsed as a YAML file."
case .DecryptionError:
return "Cannot decrypt password."
case .UnknownError:
return "Unknown error."
}
}
}