Skip to main content

nimiq_consensus/
error.rs

1//! Defines error types used across the consensus layer.
2
3use nimiq_blockchain_interface::BlockchainError;
4use serde::{Deserialize, Serialize};
5use thiserror::Error;
6
7/// Errors that can occur in the consensus layer.
8#[derive(Debug, Error)]
9pub enum Error {
10    #[error("Blockchain error: {0}")]
11    BlockchainError(#[from] BlockchainError),
12}
13/// Errors returned during synchronization.
14#[derive(Debug, Error)]
15pub enum SyncError {
16    #[error("Other")]
17    Other,
18    #[error("No valid sync target found")]
19    NoValidSyncTarget,
20}
21
22/// Different errors that can be obtained when subscribing to transaction addresses.
23#[repr(u8)]
24#[derive(Clone, Copy, Debug, Error, Eq, PartialEq, Serialize, Deserialize)]
25pub enum SubscribeToAddressesError {
26    /// Already attending too many peers
27    #[error("Too many peers")]
28    TooManyPeers = 1,
29    /// Already attending too many addresses
30    #[error("Too many addresses")]
31    TooManyAddresses = 2,
32    /// Some of the provided parameters/operations was invalid
33    #[error("Invalid operation")]
34    InvalidOperation = 3,
35    /// Another type of error not covered by the previous error types
36    #[error("Other")]
37    #[serde(other)]
38    Other = 4,
39}