passforios/passKit/Helpers/AppError.swift
Danny Moesch b503e5f613 Inform the user about a failed push
In case there are uncommitted changes in the remote repository the push ran through successfully but there were still unpushed changes in the app. This change notfies the user about this situation. Strangely, the push method from Objective-Git does not inform about this, although the command line Git does. Thus, the check for the number of local changes is used after the push operation, which can actually have several reasons. Important is that there is at least some hint, though.
2020-07-26 16:16:57 -07:00

43 lines
1.3 KiB
Swift

//
// AppError.swift
// pass
//
// Created by Mingshen Sun on 30/4/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
public enum AppError: Error, Equatable {
case RepositoryNotSet
case RepositoryRemoteBranchNotFound(_: String)
case RepositoryBranchNotFound(_: String)
case KeyImport
case ReadingFile(_: String)
case PasswordDuplicated
case GitReset
case GitCreateSignature
case GitPushNotSuccessful
case PasswordEntity
case PgpPublicKeyNotFound(keyID: String)
case PgpPrivateKeyNotFound(keyID: String)
case KeyExpiredOrIncompatible
case WrongPassphrase
case WrongPasswordFilename
case Decryption
case Encryption
case Encoding
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), let .ReadingFile(name):
return localizationKey.localize(name)
case let .PgpPublicKeyNotFound(keyID), let .PgpPrivateKeyNotFound(keyID):
return localizationKey.localize(keyID)
default:
return localizationKey.localize()
}
}
}