Added MachineError struct

This commit is contained in:
François Autin 2023-03-23 20:04:21 +01:00
parent c6ea3a0cb3
commit 87d90c394f
No known key found for this signature in database
GPG Key ID: 343F5D382E1DD77C
2 changed files with 28 additions and 0 deletions

27
src/simulator/error.rs Normal file
View File

@ -0,0 +1,27 @@
use std::fmt;
/// Machine Error
/// This error serves as a specific exception handler for the Machine struct
#[derive(Debug, Clone)]
pub struct MachineError {
/// The error message
message: String
}
impl MachineError {
pub fn new(message: &str) -> MachineError {
MachineError {
message: message.to_string()
}
}
}
impl fmt::Display for MachineError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Machine error: {}", &self.message)
}
}

View File

@ -1,4 +1,5 @@
pub mod machine;
pub mod error;
pub mod decode;
pub mod print;
pub mod mem_cmp;