summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadREST/Relay/NoRelaysSatisfyingConstraintsError.swift
blob: 10eb1df7769bc170f90bb13366a79fe8312b6202 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
//  NoRelaysSatisfyingConstraintsError.swift
//  MullvadREST
//
//  Created by Mojgan on 2024-04-26.
//  Copyright © 2025 Mullvad VPN AB. All rights reserved.
//

import Foundation

public enum NoRelaysSatisfyingConstraintsReason: Sendable {
    case filterConstraintNotMatching
    case invalidPort
    case entryEqualsExit
    case multihopInvalidFlow
    case noActiveRelaysFound
    case noDaitaRelaysFound
    case noObfuscatedRelaysFound
    case relayConstraintNotMatching
}

public struct NoRelaysSatisfyingConstraintsError: LocalizedError, Sendable {
    public let reason: NoRelaysSatisfyingConstraintsReason

    public var errorDescription: String? {
        switch reason {
        case .filterConstraintNotMatching:
            "Filter yields no matching relays"
        case .invalidPort:
            "Invalid port selected by RelaySelector"
        case .entryEqualsExit:
            "Entry and exit relays are the same"
        case .multihopInvalidFlow:
            "Invalid multihop decision flow"
        case .noActiveRelaysFound:
            "No active relays found"
        case .noDaitaRelaysFound:
            "No DAITA relays found"
        case .noObfuscatedRelaysFound:
            "No obfuscated relays found"
        case .relayConstraintNotMatching:
            "Invalid constraint created to pick a relay"
        }
    }

    public init(_ reason: NoRelaysSatisfyingConstraintsReason) {
        self.reason = reason
    }
}