1
+ use anyhow:: anyhow;
1
2
use async_trait:: async_trait;
2
3
use serde:: { Deserialize , Serialize } ;
3
4
use std:: { str:: FromStr , sync:: Arc } ;
@@ -6,7 +7,7 @@ use thiserror::Error;
6
7
use crate :: entities:: Epoch ;
7
8
use crate :: { StdError , StdResult } ;
8
9
9
- use super :: { supported_era :: UnsupportedEraError , SupportedEra } ;
10
+ use super :: SupportedEra ;
10
11
11
12
/// Value object that represents a tag of Era change.
12
13
#[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize ) ]
@@ -57,9 +58,9 @@ impl EraEpochToken {
57
58
/// Try to cast the current [EraMarker] to a [SupportedEra]. If it fails,
58
59
/// that means the current Era is not supported by this version of the
59
60
/// software.
60
- pub fn get_current_supported_era ( & self ) -> Result < SupportedEra , UnsupportedEraError > {
61
+ pub fn get_current_supported_era ( & self ) -> StdResult < SupportedEra > {
61
62
SupportedEra :: from_str ( & self . current_era . name )
62
- . map_err ( |_| UnsupportedEraError :: new ( & self . current_era . name ) )
63
+ . map_err ( |_| anyhow ! ( format! ( "Unsupported era '{}'." , & self . current_era. name) ) )
63
64
}
64
65
65
66
/// Return the [EraMarker] of the current Era.
@@ -76,11 +77,11 @@ impl EraEpochToken {
76
77
/// means the coming Era will not be supported by this version of the
77
78
/// software. This mechanism is used to issue a warning to the user asking
78
79
/// for upgrade.
79
- pub fn get_next_supported_era ( & self ) -> Result < Option < SupportedEra > , UnsupportedEraError > {
80
+ pub fn get_next_supported_era ( & self ) -> StdResult < Option < SupportedEra > > {
80
81
match self . next_era . as_ref ( ) {
81
82
Some ( marker) => Ok ( Some (
82
83
SupportedEra :: from_str ( & marker. name )
83
- . map_err ( |_| UnsupportedEraError :: new ( & self . current_era . name ) ) ?,
84
+ . map_err ( |_| anyhow ! ( format! ( "Unsupported era '{}'." , & marker . name) ) ) ?,
84
85
) ) ,
85
86
None => Ok ( None ) ,
86
87
}
0 commit comments