Add new machine error types
This commit is contained in:
parent
04f90b5152
commit
72794b8c14
1 changed files with 9 additions and 1 deletions
|
|
@ -8,14 +8,22 @@ use std::sync::mpsc::{Receiver, Sender};
|
|||
#[derive(Debug)]
|
||||
pub enum MachineError {
|
||||
BadLabel(u16),
|
||||
UnexpectedCbor(&'static str),
|
||||
InvalidMsgForState,
|
||||
}
|
||||
|
||||
impl Display for MachineError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
MachineError::BadLabel(label) => {
|
||||
write!(f, "unknown message label [{}]", label)
|
||||
write!(f, "unknown message label: {}", label)
|
||||
}
|
||||
MachineError::UnexpectedCbor(msg) => {
|
||||
write!(f, "unexpected cbor: {}", msg)
|
||||
},
|
||||
MachineError::InvalidMsgForState => {
|
||||
write!(f, "received invalid message for current state")
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue