File tree Expand file tree Collapse file tree 3 files changed +19
-5
lines changed
mithril-aggregator/src/runtime Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -60,9 +60,6 @@ pub enum RuntimeError {
60
60
#[ error( "signer registration error: {0}" ) ]
61
61
SignerRegistration ( #[ from] SignerRegistrationError ) ,
62
62
63
- #[ error( "era not supported: {0}" ) ]
64
- EraNotSupported ( String ) ,
65
-
66
63
#[ error( "general error: {0}" ) ]
67
64
General ( Box < dyn StdError + Sync + Send > ) ,
68
65
}
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ impl EraEpochToken {
57
57
/// software.
58
58
pub fn get_current_supported_era ( & self ) -> Result < SupportedEra , UnsupportedEraError > {
59
59
SupportedEra :: from_str ( & self . current_era . name )
60
+ . map_err ( |_| UnsupportedEraError :: new ( & self . current_era . name ) )
60
61
}
61
62
62
63
/// Return the [EraMarker] of the current Era.
@@ -75,7 +76,10 @@ impl EraEpochToken {
75
76
/// for upgrade.
76
77
pub fn get_next_supported_era ( & self ) -> Result < Option < SupportedEra > , UnsupportedEraError > {
77
78
match self . next_era . as_ref ( ) {
78
- Some ( marker) => Ok ( Some ( SupportedEra :: from_str ( & marker. name ) ?) ) ,
79
+ Some ( marker) => Ok ( Some (
80
+ SupportedEra :: from_str ( & marker. name )
81
+ . map_err ( |_| UnsupportedEraError :: new ( & self . current_era . name ) ) ?,
82
+ ) ) ,
79
83
None => Ok ( None ) ,
80
84
}
81
85
}
Original file line number Diff line number Diff line change 1
1
use serde:: { Deserialize , Serialize } ;
2
2
use strum:: IntoEnumIterator ;
3
3
use strum_macros:: { Display , EnumIter , EnumString } ;
4
+ use thiserror:: Error ;
4
5
5
6
/// Error related to [SupportedEra] String parsing implementation.
6
- pub type UnsupportedEraError = strum:: ParseError ;
7
+ #[ derive( Debug , Error ) ]
8
+ #[ error( "Unsupported Era '{era}'." ) ]
9
+ pub struct UnsupportedEraError {
10
+ era : String ,
11
+ }
12
+
13
+ impl UnsupportedEraError {
14
+ pub fn new ( era : & str ) -> Self {
15
+ Self {
16
+ era : era. to_owned ( ) ,
17
+ }
18
+ }
19
+ }
7
20
8
21
/// The era that the software is running or will run
9
22
#[ derive(
You can’t perform that action at this time.
0 commit comments