mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.3 KiB
Swift
31 lines
1.3 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
import SessionUtilitiesKit
|
|
|
|
public enum OnionRequestAPIError: LocalizedError {
|
|
case httpRequestFailedAtDestination(statusCode: UInt, data: Data, destination: OnionRequestAPIDestination)
|
|
case insufficientSnodes
|
|
case invalidURL
|
|
case missingSnodeVersion
|
|
case snodePublicKeySetMissing
|
|
case unsupportedSnodeVersion(String)
|
|
case invalidRequestInfo
|
|
|
|
public var errorDescription: String? {
|
|
switch self {
|
|
case .httpRequestFailedAtDestination(let statusCode, _, let destination):
|
|
if statusCode == 429 { return "Rate limited." }
|
|
|
|
return "HTTP request failed at destination (\(destination)) with status code: \(statusCode)."
|
|
|
|
case .insufficientSnodes: return "Couldn't find enough Service Nodes to build a path."
|
|
case .invalidURL: return "Invalid URL"
|
|
case .missingSnodeVersion: return "Missing Service Node version."
|
|
case .snodePublicKeySetMissing: return "Missing Service Node public key set."
|
|
case .unsupportedSnodeVersion(let version): return "Unsupported Service Node version: \(version)."
|
|
case .invalidRequestInfo: return "Invalid Request Info"
|
|
}
|
|
}
|
|
}
|