♻️ Error cleanup
This commit is contained in:
parent
7f37965ed4
commit
40039eca17
@ -14,7 +14,7 @@
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
use std::fmt::{self, Error};
|
||||
use std::fmt;
|
||||
|
||||
/// Machine Error
|
||||
/// This error serves as a specific exception handler for the Machine struct
|
||||
@ -24,23 +24,22 @@ pub struct MachineError {
|
||||
message: String
|
||||
}
|
||||
|
||||
impl MachineError {
|
||||
|
||||
/// MachineError constructor
|
||||
pub fn new(message: &str) -> MachineError {
|
||||
MachineError {
|
||||
message: message.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// This impl allows this MachineError to be formatted into an empty format.
|
||||
///
|
||||
/// ```
|
||||
/// // Result of printing a MachineError
|
||||
/// let m = MachineError::new("Lorem Ipsum");
|
||||
/// println!("Example: {}", m);
|
||||
/// ```
|
||||
///
|
||||
/// Console output:Error}
|
||||
/// ```
|
||||
/// example Lorem Ipsum
|
||||
/// ```
|
||||
impl fmt::Display for MachineError {
|
||||
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "Machine error: {}", &self.message)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl From<&str> for MachineError {
|
||||
|
Loading…
Reference in New Issue
Block a user