|
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; |
9 | 1 | use std::error::Error as StdError;
|
10 | 2 | use thiserror::Error;
|
11 | 3 |
|
@@ -53,65 +45,36 @@ impl RuntimeError {
|
53 | 45 | }
|
54 | 46 | }
|
55 | 47 |
|
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 { |
58 | 50 | 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), |
61 | 53 | }
|
62 | 54 | }
|
63 | 55 | }
|
64 | 56 |
|
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), |
73 | 64 |
|
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), |
82 | 68 |
|
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), |
91 | 72 |
|
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), |
109 | 76 |
|
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), |
117 | 80 | }
|
0 commit comments