dfx_core/error/
network_config.rs

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
50
51
52
53
54
55
56
57
58
59
60
use crate::error::config::{ConfigError, GetTempPathError};
use crate::error::fs::ReadToStringError;
use crate::error::socket_addr_conversion::SocketAddrConversionError;
use crate::error::uri::UriError;

use candid::types::principal::PrincipalError;
use std::num::ParseIntError;
use std::path::PathBuf;
use thiserror::Error;

#[derive(Error, Debug)]
pub enum NetworkConfigError {
    #[error(transparent)]
    ReadToString(#[from] ReadToStringError),

    #[error(transparent)]
    Config(#[from] ConfigError),

    #[error(transparent)]
    UriError(#[from] UriError),

    #[error("Failed to get replica endpoint for network '{network_name}'")]
    GettingReplicaUrlsFailed {
        network_name: String,
        source: UriError,
    },

    #[error(transparent)]
    GetTempPath(#[from] GetTempPathError),

    #[error("Network '{0}' does not specify any network providers.")]
    NetworkHasNoProviders(String),

    #[error("The '{0}' network must be a local network.")]
    NetworkMustBeLocal(String),

    #[error("Network not found: {0}")]
    NetworkNotFound(String),

    #[error("Cannot find network context.")]
    NoNetworkContext(),

    #[error("Did not find any providers for network '{0}'")]
    NoProvidersForNetwork(String),

    #[error("Failed to parse bind address")]
    ParseBindAddressFailed(#[source] SocketAddrConversionError),

    #[error("Failed to parse contents of {0} as a port value")]
    ParsePortValueFailed(Box<PathBuf>, #[source] Box<ParseIntError>),

    #[error("Failed to parse URL '{0}'")]
    ParseProviderUrlFailed(Box<String>, #[source] url::ParseError),

    #[error("Failed to read webserver port")]
    ReadWebserverPortFailed(#[source] ReadToStringError),

    #[error("Failed to parse principal '{0}'")]
    ParsePrincipalFailed(String, #[source] PrincipalError),
}