♻️ Error cleanup

This commit is contained in:
François Autin 2023-03-28 19:37:31 +02:00
parent 7f37965ed4
commit 40039eca17
No known key found for this signature in database
GPG Key ID: 343F5D382E1DD77C

View File

@ -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 {