mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-08 22:38:01 -06:00
Remove error type
This commit is contained in:
@@ -1,70 +0,0 @@
|
|||||||
use std::fmt;
|
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, ModuleError>;
|
|
||||||
|
|
||||||
///Generic error type for module-related operations.
|
|
||||||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
||||||
pub enum ModuleError {
|
|
||||||
NoError,
|
|
||||||
|
|
||||||
// Tree errors
|
|
||||||
TreeNotExist,
|
|
||||||
TreeMessageError(String),
|
|
||||||
|
|
||||||
// Object errors
|
|
||||||
UnsupportedMethod,
|
|
||||||
InvalidType,
|
|
||||||
|
|
||||||
LibLoadingError(String),
|
|
||||||
// LogError(log::SetLoggerError),
|
|
||||||
LinkError(String),
|
|
||||||
CryptError(String),
|
|
||||||
DatabaseError(String),
|
|
||||||
SerdeJsonError(String),
|
|
||||||
|
|
||||||
Error(String),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<&str> for ModuleError {
|
|
||||||
fn from(value: &str) -> Self {
|
|
||||||
Self::Error(value.into())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<serde_json::Error> for ModuleError {
|
|
||||||
fn from(value: serde_json::Error) -> Self {
|
|
||||||
Self::SerdeJsonError(value.to_string())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Box<dyn std::error::Error>> for ModuleError {
|
|
||||||
fn from(value: Box<dyn std::error::Error>) -> Self {
|
|
||||||
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())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ModuleError> for std::string::String {
|
|
||||||
fn from(value: ModuleError) -> Self {
|
|
||||||
value.to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
mod error;
|
|
||||||
pub mod logger;
|
pub mod logger;
|
||||||
pub mod tree;
|
pub mod tree;
|
||||||
|
|
||||||
pub use error::{ModuleError, Result};
|
|
||||||
|
|
||||||
// Re-exports
|
// Re-exports
|
||||||
pub use serde_json::{Value, json};
|
pub use serde_json::{Value, json};
|
||||||
pub use ush_obfuscate as obfuscate;
|
pub use ush_obfuscate as obfuscate;
|
||||||
|
|||||||
Reference in New Issue
Block a user