Add new machine error types
This commit is contained in:
parent
8a9ab62959
commit
4cdddd331b
1 changed files with 9 additions and 1 deletions
|
|
@ -8,14 +8,22 @@ use std::sync::mpsc::{Receiver, Sender};
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum MachineError {
|
pub enum MachineError {
|
||||||
BadLabel(u16),
|
BadLabel(u16),
|
||||||
|
UnexpectedCbor(&'static str),
|
||||||
|
InvalidMsgForState,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for MachineError {
|
impl Display for MachineError {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
MachineError::BadLabel(label) => {
|
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