Skip to content

Commit 1a25c7b

Browse files
committed
rework signer runner errors
1 parent 8d55db3 commit 1a25c7b

File tree

6 files changed

+190
-216
lines changed

6 files changed

+190
-216
lines changed
Lines changed: 23 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
use crate::ProtocolError;
2-
3-
use mithril_common::certificate_chain::CertificateVerifierError;
4-
use mithril_common::chain_observer::ChainObserverError;
5-
use mithril_common::digesters::ImmutableDigesterError;
6-
use mithril_common::entities::BeaconComparisonError;
7-
use mithril_common::store::StoreError;
8-
use mithril_common::BeaconProviderError;
91
use std::error::Error as StdError;
102
use thiserror::Error;
113

@@ -53,65 +45,36 @@ impl RuntimeError {
5345
}
5446
}
5547

56-
impl From<BeaconComparisonError> for RuntimeError {
57-
fn from(value: BeaconComparisonError) -> Self {
48+
impl From<Box<dyn StdError + Sync + Send>> for RuntimeError {
49+
fn from(value: Box<dyn StdError + Sync + Send>) -> Self {
5850
Self::KeepState {
59-
message: "Beacon comparison error".to_string(),
60-
nested_error: Some(value.into()),
51+
message: "Error caught, state preserved, will retry to cycle.".to_string(),
52+
nested_error: Some(value),
6153
}
6254
}
6355
}
6456

65-
impl From<ImmutableDigesterError> for RuntimeError {
66-
fn from(value: ImmutableDigesterError) -> Self {
67-
Self::KeepState {
68-
message: "Error while reading immutable files".to_string(),
69-
nested_error: Some(value.into()),
70-
}
71-
}
72-
}
57+
/// Errors returned when the runner cannot fulfil its missions with no subsystem
58+
/// to fail.
59+
#[derive(Debug, Error)]
60+
pub enum RunnerError {
61+
/// Protocol message part is missing
62+
#[error("Missing protocol message: '{0}'.")]
63+
MissingProtocolMessage(String),
7364

74-
impl From<ProtocolError> for RuntimeError {
75-
fn from(value: ProtocolError) -> Self {
76-
Self::KeepState {
77-
message: "Mithril Protocol Error".to_string(),
78-
nested_error: Some(value.into()),
79-
}
80-
}
81-
}
65+
/// Epoch out of bounds
66+
#[error("Epoch out of bounds: '{0}'.")]
67+
EpochOutOfBounds(String),
8268

83-
impl From<ChainObserverError> for RuntimeError {
84-
fn from(value: ChainObserverError) -> Self {
85-
Self::KeepState {
86-
message: "Chain observer error".to_string(),
87-
nested_error: Some(value.into()),
88-
}
89-
}
90-
}
69+
/// No stack distribution found
70+
#[error("Missing stack distribution: '{0}'.")]
71+
MissingStakeDistribution(String),
9172

92-
impl From<StoreError> for RuntimeError {
93-
fn from(value: StoreError) -> Self {
94-
Self::KeepState {
95-
message: "Store Error".to_string(),
96-
nested_error: Some(value.into()),
97-
}
98-
}
99-
}
100-
101-
impl From<BeaconProviderError> for RuntimeError {
102-
fn from(value: BeaconProviderError) -> Self {
103-
Self::KeepState {
104-
message: "Could not read beacon from chain".to_string(),
105-
nested_error: Some(value.into()),
106-
}
107-
}
108-
}
73+
/// Missing protocol parameters
74+
#[error("Missing protocol parameters: '{0}'.")]
75+
MissingProtocolParameters(String),
10976

110-
impl From<CertificateVerifierError> for RuntimeError {
111-
fn from(value: CertificateVerifierError) -> Self {
112-
Self::KeepState {
113-
message: "Could not verify given certificate".to_string(),
114-
nested_error: Some(value.into()),
115-
}
116-
}
77+
/// No AVK issued by the multisigner
78+
#[error("No MultiSignature issued: '{0}'.")]
79+
NoComputedMultiSignature(String),
11780
}

0 commit comments

Comments
 (0)