mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-09 06:47:59 -06:00
Configurable Struct
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
use std::fmt;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, ModuleError>;
|
||||
|
||||
///Generic error type for module-related operations.
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub enum ModuleError {
|
||||
@@ -30,3 +34,23 @@ impl From<Box<dyn std::error::Error>> for ModuleError {
|
||||
ModuleError::Error(value.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for ModuleError {
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
None
|
||||
}
|
||||
|
||||
fn description(&self) -> &str {
|
||||
"description() is deprecated; use Display"
|
||||
}
|
||||
|
||||
fn cause(&self) -> Option<&dyn std::error::Error> {
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ModuleError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.write_str(format!("{:?}", self).as_str())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user