Changed the SnodeAPIError to be CustomStringConvertible

pull/960/head
Morgan Pretty 1 year ago
parent 4818a6d074
commit 0f370ab667

@ -221,17 +221,14 @@ final class NewDMVC: BaseVC, UIPageViewControllerDataSource, UIPageViewControlle
case .finished: break case .finished: break
case .failure(let error): case .failure(let error):
modalActivityIndicator.dismiss { modalActivityIndicator.dismiss {
var messageOrNil: String?
if let error = error as? SnodeAPIError {
switch error {
case .decryptionFailed, .hashingFailed, .validationFailed:
messageOrNil = error.errorDescription
default: break
}
}
let message: String = { let message: String = {
if let messageOrNil: String = messageOrNil { if let error = error as? SnodeAPIError {
return messageOrNil switch error {
case .decryptionFailed, .hashingFailed, .validationFailed:
return "\(error)"
default: break
}
} }
return (maybeSessionId?.prefix == .blinded15 || maybeSessionId?.prefix == .blinded25 ? return (maybeSessionId?.prefix == .blinded15 || maybeSessionId?.prefix == .blinded25 ?

@ -5,7 +5,7 @@
import Foundation import Foundation
import SessionUtilitiesKit import SessionUtilitiesKit
public enum SnodeAPIError: LocalizedError { public enum SnodeAPIError: Error, CustomStringConvertible {
case clockOutOfSync case clockOutOfSync
case snodePoolUpdatingFailed case snodePoolUpdatingFailed
case inconsistentSnodePools case inconsistentSnodePools
@ -34,35 +34,35 @@ public enum SnodeAPIError: LocalizedError {
case unreachable case unreachable
case unassociatedPubkey case unassociatedPubkey
public var errorDescription: String? { public var description: String {
switch self { switch self {
case .clockOutOfSync: return "Your clock is out of sync with the Service Node network. Please check that your device's clock is set to automatic time." case .clockOutOfSync: return "Your clock is out of sync with the Service Node network. Please check that your device's clock is set to automatic time (SnodeAPIError.clockOutOfSync)."
case .snodePoolUpdatingFailed: return "Failed to update the Service Node pool." case .snodePoolUpdatingFailed: return "Failed to update the Service Node pool (SnodeAPIError.snodePoolUpdatingFailed)."
case .inconsistentSnodePools: return "Received inconsistent Service Node pool information from the Service Node network." case .inconsistentSnodePools: return "Received inconsistent Service Node pool information from the Service Node network (SnodeAPIError.inconsistentSnodePools)."
case .noKeyPair: return "Missing user key pair." case .noKeyPair: return "Missing user key pair (SnodeAPIError.noKeyPair)."
case .signingFailed: return "Couldn't sign message." case .signingFailed: return "Couldn't sign message (SnodeAPIError.signingFailed)."
case .signatureVerificationFailed: return "Failed to verify the signature." case .signatureVerificationFailed: return "Failed to verify the signature (SnodeAPIError.signatureVerificationFailed)."
case .invalidIP: return "Invalid IP." case .invalidIP: return "Invalid IP (SnodeAPIError.invalidIP)."
case .responseFailedValidation: return "Response failed validation." case .responseFailedValidation: return "Response failed validation (SnodeAPIError.responseFailedValidation)."
case .rateLimited: return "Rate limited." case .rateLimited: return "Rate limited (SnodeAPIError.rateLimited)."
case .missingSnodeVersion: return "Missing Service Node version." case .missingSnodeVersion: return "Missing Service Node version (SnodeAPIError.missingSnodeVersion)."
case .unsupportedSnodeVersion(let version): return "Unsupported Service Node version: \(version)." case .unsupportedSnodeVersion(let version): return "Unsupported Service Node version: \(version) (SnodeAPIError.unsupportedSnodeVersion)."
// Onion Request Errors // Onion Request Errors
case .emptySnodePool: return "Service Node pool is empty." case .emptySnodePool: return "Service Node pool is empty (SnodeAPIError.emptySnodePool)."
case .insufficientSnodes: return "Couldn't find enough Service Nodes to build a path." case .insufficientSnodes: return "Couldn't find enough Service Nodes to build a path (SnodeAPIError.insufficientSnodes)."
case .ranOutOfRandomSnodes: return "Ran out of random snodes to send the request through." case .ranOutOfRandomSnodes: return "Ran out of random snodes to send the request through (SnodeAPIError.ranOutOfRandomSnodes)."
// ONS // ONS
case .decryptionFailed: return "Couldn't decrypt ONS name." case .decryptionFailed: return "Couldn't decrypt ONS name (SnodeAPIError.decryptionFailed)."
case .hashingFailed: return "Couldn't compute ONS name hash." case .hashingFailed: return "Couldn't compute ONS name hash (SnodeAPIError.hashingFailed)."
case .validationFailed: return "ONS name validation failed." case .validationFailed: return "ONS name validation failed (SnodeAPIError.validationFailed)."
// Quic // Quic
case .invalidPayload: return "Invalid payload." case .invalidPayload: return "Invalid payload (SnodeAPIError.invalidPayload)."
case .missingSecretKey: return "Missing secret key." case .missingSecretKey: return "Missing secret key (SnodeAPIError.missingSecretKey)."
case .unreachable: return "The service node is unreachable." case .unreachable: return "The service node is unreachable (SnodeAPIError.unreachable)."
case .unassociatedPubkey: return "The service node is no longer associated with the public key." case .unassociatedPubkey: return "The service node is no longer associated with the public key (SnodeAPIError.unassociatedPubkey)."
} }
} }
} }

Loading…
Cancel
Save