nym_bandwidth_controller/
error.rs1use nym_credential_storage::error::StorageError;
5use nym_credentials::error::Error as CredentialsError;
6use nym_credentials_interface::CompactEcashError;
7use nym_crypto::asymmetric::ed25519::Ed25519RecoveryError;
8use nym_crypto::asymmetric::x25519::KeyRecoveryError;
9use nym_validator_client::coconut::EcashApiError;
10use nym_validator_client::error::ValidatorClientError;
11use thiserror::Error;
12
13#[derive(Debug, Error)]
14pub enum BandwidthControllerError {
15 #[error("Nyxd error: {0}")]
16 Nyxd(#[from] nym_validator_client::nyxd::error::NyxdError),
17
18 #[error("coconut api query failure: {0}")]
19 CoconutApiError(#[from] EcashApiError),
20
21 #[error("There was a credential storage error - {0}")]
22 CredentialStorageError(Box<dyn std::error::Error + Send + Sync>),
23
24 #[error("retrieved upgrade mode token is not a valid String")]
25 MalformedUpgradeModeToken,
26
27 #[error("the credential storage does not contain any usable credentials")]
28 NoCredentialsAvailable,
29
30 #[error(transparent)]
32 StorageError(#[from] StorageError),
33
34 #[error("Ecash error - {0}")]
35 EcashError(#[from] CompactEcashError),
36
37 #[error("Validator client error - {0}")]
38 ValidatorError(#[from] ValidatorClientError),
39
40 #[error("Credential error - {0}")]
41 CredentialError(#[from] CredentialsError),
42
43 #[error("Could not parse Ed25519 data")]
44 Ed25519ParseError(#[from] Ed25519RecoveryError),
45
46 #[error("Could not parse X25519 data")]
47 X25519ParseError(#[from] KeyRecoveryError),
48
49 #[error("The tx hash provided is not valid")]
50 InvalidTxHash,
51
52 #[error("Threshold not set yet")]
53 NoThreshold,
54
55 #[error("can't handle recovering storage with revision {stored}. {expected} was expected")]
56 UnsupportedCredentialStorageRevision { stored: u8, expected: u8 },
57
58 #[error("did not receive a valid response for aggregated data ({typ}) from ANY nym-api")]
59 ExhaustedApiQueries { typ: String },
60}
61
62impl BandwidthControllerError {
63 pub fn credential_storage_error(
64 source: impl std::error::Error + Send + Sync + 'static,
65 ) -> Self {
66 BandwidthControllerError::CredentialStorageError(Box::new(source))
67 }
68}