Impl display for error
This commit is contained in:
parent
60b9d875f1
commit
94e89466e6
|
@ -1,6 +1,23 @@
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum FBError {
|
pub enum FBError {
|
||||||
DecodeError,
|
DecodeError,
|
||||||
InvalidKey,
|
InvalidKey,
|
||||||
InvalidParams,
|
InvalidParams,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for FBError {
|
||||||
|
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let message = match self {
|
||||||
|
FBError::DecodeError => "Invalid input",
|
||||||
|
FBError::InvalidKey => "Invalid Key used",
|
||||||
|
FBError::InvalidParams => "Keybase len(k) or Cipher len(n) out of bounds. Valid bounds: (2 <= k <= n)",
|
||||||
|
};
|
||||||
|
|
||||||
|
f.write_fmt(format_args!("{message}"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::error::Error for FBError {}
|
||||||
|
|
Loading…
Reference in New Issue