Skip to content

Commit 5e6c264

Browse files
committed
chore: add thiserror and DBError to NakamotoNodeError
1 parent c8f1d99 commit 5e6c264

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

testnet/stacks-node/src/nakamoto_node.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use stacks::monitoring::update_active_miners_count_gauge;
2828
use stacks::net::atlas::AtlasConfig;
2929
use stacks::net::relay::Relayer;
3030
use stacks::net::stackerdb::StackerDBs;
31+
use stacks::util_lib::db::Error as DBError;
3132
use stacks_common::types::chainstate::SortitionId;
3233
use stacks_common::types::StacksEpochId;
3334

@@ -71,46 +72,70 @@ pub struct StacksNode {
7172
}
7273

7374
/// Types of errors that can arise during Nakamoto StacksNode operation
74-
#[derive(Debug)]
75+
#[derive(thiserror::Error, Debug)]
7576
pub enum Error {
7677
/// Can't find the block sortition snapshot for the chain tip
78+
#[error("Can't find the block sortition snapshot for the chain tip")]
7779
SnapshotNotFoundForChainTip,
7880
/// The burnchain tip changed while this operation was in progress
81+
#[error("The burnchain tip changed while this operation was in progress")]
7982
BurnchainTipChanged,
8083
/// The Stacks tip changed while this operation was in progress
84+
#[error("The Stacks tip changed while this operation was in progress")]
8185
StacksTipChanged,
8286
/// Signers rejected a block
87+
#[error("Signers rejected a block")]
8388
SignersRejected,
8489
/// Error while spawning a subordinate thread
90+
#[error("Error while spawning a subordinate thread: {0}")]
8591
SpawnError(std::io::Error),
8692
/// Injected testing errors
93+
#[error("Injected testing errors")]
8794
FaultInjection,
8895
/// This miner was elected, but another sortition occurred before mining started
96+
#[error("This miner was elected, but another sortition occurred before mining started")]
8997
MissedMiningOpportunity,
9098
/// Attempted to mine while there was no active VRF key
99+
#[error("Attempted to mine while there was no active VRF key")]
91100
NoVRFKeyActive,
92101
/// The parent block or tenure could not be found
102+
#[error("The parent block or tenure could not be found")]
93103
ParentNotFound,
94104
/// Something unexpected happened (e.g., hash mismatches)
105+
#[error("Something unexpected happened (e.g., hash mismatches)")]
95106
UnexpectedChainState,
96107
/// A burnchain operation failed when submitting it to the burnchain
108+
#[error("A burnchain operation failed when submitting it to the burnchain: {0}")]
97109
BurnchainSubmissionFailed(BurnchainsError),
98110
/// A new parent has been discovered since mining started
111+
#[error("A new parent has been discovered since mining started")]
99112
NewParentDiscovered,
100113
/// A failure occurred while constructing a VRF Proof
114+
#[error("A failure occurred while constructing a VRF Proof")]
101115
BadVrfConstruction,
116+
#[error("The miner didn't accept their own block")]
102117
CannotSelfSign,
118+
#[error("A failure occurred while mining: {0}")]
103119
MiningFailure(ChainstateError),
104120
/// The miner didn't accept their own block
121+
#[error("The miner didn't accept their own block: {0}")]
105122
AcceptFailure(ChainstateError),
123+
#[error("A failure occurred while signing a miner's block: {0}")]
106124
MinerSignatureError(&'static str),
125+
#[error("A failure occurred while signing a signer's block: {0}")]
107126
SignerSignatureError(String),
108127
/// A failure occurred while configuring the miner thread
128+
#[error("A failure occurred while configuring the miner thread: {0}")]
109129
MinerConfigurationFailed(&'static str),
110130
/// An error occurred while operating as the signing coordinator
131+
#[error("An error occurred while operating as the signing coordinator: {0}")]
111132
SigningCoordinatorFailure(String),
112133
// The thread that we tried to send to has closed
134+
#[error("The thread that we tried to send to has closed")]
113135
ChannelClosed,
136+
/// DBError wrapper
137+
#[error("DBError: {0}")]
138+
DBError(#[from] DBError),
114139
}
115140

116141
impl StacksNode {

0 commit comments

Comments
 (0)