2017-04-30 16:16:52 -05:00
|
|
|
//
|
|
|
|
|
// AppError.swift
|
|
|
|
|
// pass
|
|
|
|
|
//
|
|
|
|
|
// Created by Mingshen Sun on 30/4/2017.
|
|
|
|
|
// Copyright © 2017 Bob Sun. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
2017-06-14 00:25:38 +08:00
|
|
|
public enum AppError: Error {
|
2017-04-30 16:16:52 -05:00
|
|
|
case RepositoryNotSetError
|
|
|
|
|
case RepositoryRemoteMasterNotFoundError
|
|
|
|
|
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
|
2018-11-10 22:38:12 -08:00
|
|
|
case DecryptionError
|
2017-04-30 16:16:52 -05:00
|
|
|
case UnknownError
|
2017-05-11 22:55:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extension AppError: LocalizedError {
|
|
|
|
|
public var errorDescription: String? {
|
2017-04-30 16:16:52 -05:00
|
|
|
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:
|
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."
|
2018-11-10 22:38:12 -08:00
|
|
|
case .DecryptionError:
|
|
|
|
|
return "Cannot decrypt password."
|
2017-04-30 16:16:52 -05:00
|
|
|
case .UnknownError:
|
|
|
|
|
return "Unknown error."
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|