feat: add error handling
This commit is contained in:
1 parent
7fc4d12eef
commit
e53b61904d
3 files changed
+191
-31
No files matched your search
+22
@@ -1,2 +1,24 @@
|
||||
mod machine;
|
||||
mod tape;
|
||||
|
||||
use std::fmt::Display;
|
||||
|
||||
pub use machine::NextState;
|
||||
pub use machine::StateId;
|
||||
pub use machine::TuringMachine;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum TuringMachineError {
|
||||
DuplicateStateEntryKey(String),
|
||||
StateEntryParsing(String),
|
||||
}
|
||||
|
||||
impl Display for TuringMachineError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
use TuringMachineError::*;
|
||||
match self {
|
||||
DuplicateStateEntryKey(key) => write!(f, "duplicate key in state table: {}", key),
|
||||
StateEntryParsing(entry) => write!(f, "could not parse state entry: {}", entry),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user