Improve error formatting for WeightedError
This commit is contained in:
@@ -439,15 +439,15 @@ pub enum WeightedError {
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl ::std::error::Error for WeightedError {}
|
||||
impl std::error::Error for WeightedError {}
|
||||
|
||||
impl fmt::Display for WeightedError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
WeightedError::NoItem => write!(f, "No weights provided."),
|
||||
WeightedError::InvalidWeight => write!(f, "A weight is invalid."),
|
||||
WeightedError::AllWeightsZero => write!(f, "All weights are zero."),
|
||||
WeightedError::TooMany => write!(f, "Too many weights (hit u32::MAX)"),
|
||||
}
|
||||
f.write_str(match *self {
|
||||
WeightedError::NoItem => "No weights provided in distribution",
|
||||
WeightedError::InvalidWeight => "A weight is invalid in distribution",
|
||||
WeightedError::AllWeightsZero => "All weights are zero in distribution",
|
||||
WeightedError::TooMany => "Too many weights (hit u32::MAX) in distribution",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user