Skip to content

Commit b06e566

Browse files
committed
add error type instead of expect
1 parent 8b74141 commit b06e566

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

toolkit/committee-selection/authority-selection-inherents/src/ariadne_inherent_data_provider.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@ impl AriadneInherentDataProvider {
6262
timestamp_millis,
6363
)?;
6464

65-
let data_epoch = offset_data_epoch(&for_mc_epoch).expect(&format!(
66-
"Could not apply data offset to MC epoch {} for authority selection; this is caused either by misconfiguration or a bug.",
67-
for_mc_epoch.0,
68-
));
65+
let data_epoch = offset_data_epoch(&for_mc_epoch).map_err(|offset| {
66+
InherentProviderCreationError::McEpochOffsetError(offset, for_mc_epoch)
67+
})?;
6968

7069
// We could accept mc_reference at last slot of data_epoch, but calculations are much easier like that.
7170
// Additionally, in current implementation, the inequality below is always true, thus there is no need to make it more accurate.
@@ -100,6 +99,10 @@ pub enum InherentProviderCreationError {
10099
/// Couldn't convert timestamp to main chain epoch.
101100
#[error("Couldn't convert timestamp to main chain epoch: {0}")]
102101
McEpochDerivationError(#[from] sidechain_domain::mainchain_epoch::EpochDerivationError),
102+
#[error(
103+
"Could not apply data offset of {0} to MC epoch {1:?} for authority selection; this is caused either by a node misconfiguration or a bug."
104+
)]
105+
McEpochOffsetError(u32, McEpochNumber),
103106
/// Runtime API call failed.
104107
#[error("Runtime API call failed: {0}")]
105108
ApiError(#[from] sp_api::ApiError),

0 commit comments

Comments
 (0)