use backhand::BackhandError; use cli_tables::TableError; use oci_spec::OciSpecError; use std::error::Error; use std::fmt::{Display, Formatter}; use std::num::ParseIntError; use std::path::StripPrefixError; use xenclient::XenClientError; use xenstore::bus::XsdBusError; pub type Result = std::result::Result; #[derive(Debug)] pub struct HyphaError { message: String, } impl HyphaError { pub fn new(msg: &str) -> HyphaError { HyphaError { message: msg.to_string(), } } } impl Display for HyphaError { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.message) } } impl Error for HyphaError { fn description(&self) -> &str { &self.message } } impl From for HyphaError { fn from(value: std::io::Error) -> Self { HyphaError::new(value.to_string().as_str()) } } impl From for HyphaError { fn from(value: XenClientError) -> Self { HyphaError::new(value.to_string().as_str()) } } impl From for HyphaError { fn from(value: walkdir::Error) -> Self { HyphaError::new(value.to_string().as_str()) } } impl From for HyphaError { fn from(value: StripPrefixError) -> Self { HyphaError::new(value.to_string().as_str()) } } impl From for HyphaError { fn from(value: BackhandError) -> Self { HyphaError::new(value.to_string().as_str()) } } impl From for HyphaError { fn from(value: serde_json::Error) -> Self { HyphaError::new(value.to_string().as_str()) } } impl From for HyphaError { fn from(value: ureq::Error) -> Self { HyphaError::new(value.to_string().as_str()) } } impl From for HyphaError { fn from(value: ParseIntError) -> Self { HyphaError::new(value.to_string().as_str()) } } impl From for HyphaError { fn from(value: OciSpecError) -> Self { HyphaError::new(value.to_string().as_str()) } } impl From for HyphaError { fn from(value: url::ParseError) -> Self { HyphaError::new(value.to_string().as_str()) } } impl From for HyphaError { fn from(value: std::fmt::Error) -> Self { HyphaError::new(value.to_string().as_str()) } } impl From for HyphaError { fn from(value: uuid::Error) -> Self { HyphaError::new(value.to_string().as_str()) } } impl From for HyphaError { fn from(value: XsdBusError) -> Self { HyphaError::new(value.to_string().as_str()) } } impl From for HyphaError { fn from(value: TableError) -> Self { HyphaError::new(value.to_string().as_str()) } }