Skip to main content

nym_node_requests/
error.rs

1// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
2// SPDX-License-Identifier: Apache-2.0
3
4use thiserror::Error;
5
6#[derive(Debug, Error)]
7pub enum Error {
8    #[error("failed to serialize json data: {source}")]
9    JsonSerializationFailure {
10        #[from]
11        source: serde_json::Error,
12    },
13
14    #[error(transparent)]
15    WireguardError {
16        #[from]
17        source: nym_wireguard_types::Error,
18    },
19
20    #[cfg(feature = "client")]
21    #[error("node {node_id} has provided malformed host information ({host}: {source})")]
22    MalformedHost {
23        host: String,
24
25        node_id: u32,
26
27        #[source]
28        source: Box<crate::api::client::NymNodeApiClientError>,
29    },
30
31    #[cfg(feature = "client")]
32    #[error("failed to query node {node_id} at host {host}: {source}")]
33    QueryFailure {
34        host: String,
35
36        node_id: u32,
37
38        #[source]
39        source: Box<crate::api::client::NymNodeApiClientError>,
40    },
41
42    #[cfg(feature = "client")]
43    #[error(
44        "node {node_id} with host '{host}' doesn't seem to expose its declared http port nor any of the standard API ports, i.e.: 80, 443 or {}",
45        nym_network_defaults::DEFAULT_NYM_NODE_HTTP_PORT
46    )]
47    NoHttpPortsAvailable { host: String, node_id: u32 },
48
49    #[cfg(feature = "client")]
50    #[error("could not verify signed host information for node {node_id}")]
51    MissignedHostInformation { node_id: u32 },
52
53    #[cfg(feature = "client")]
54    #[error("identity of node {node_id} does not match. expected {expected} but got {got}")]
55    MismatchedIdentity {
56        node_id: u32,
57        expected: String,
58        got: String,
59    },
60}