2024-01-17 22:29:05 +00:00
|
|
|
use backhand::BackhandError;
|
2024-01-22 01:21:19 +00:00
|
|
|
use cli_tables::TableError;
|
2024-01-18 18:16:59 +00:00
|
|
|
use oci_spec::OciSpecError;
|
2024-01-17 16:18:12 +00:00
|
|
|
use std::error::Error;
|
|
|
|
use std::fmt::{Display, Formatter};
|
2024-01-18 18:16:59 +00:00
|
|
|
use std::num::ParseIntError;
|
2024-01-17 22:29:05 +00:00
|
|
|
use std::path::StripPrefixError;
|
2024-01-17 16:18:12 +00:00
|
|
|
use xenclient::XenClientError;
|
2024-01-21 09:58:07 +00:00
|
|
|
use xenstore::bus::XsdBusError;
|
2024-01-17 16:18:12 +00:00
|
|
|
|
|
|
|
pub type Result<T> = std::result::Result<T, HyphaError>;
|
|
|
|
|
|
|
|
#[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<std::io::Error> for HyphaError {
|
|
|
|
fn from(value: std::io::Error) -> Self {
|
|
|
|
HyphaError::new(value.to_string().as_str())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<XenClientError> for HyphaError {
|
|
|
|
fn from(value: XenClientError) -> Self {
|
|
|
|
HyphaError::new(value.to_string().as_str())
|
|
|
|
}
|
|
|
|
}
|
2024-01-17 22:29:05 +00:00
|
|
|
|
|
|
|
impl From<walkdir::Error> for HyphaError {
|
|
|
|
fn from(value: walkdir::Error) -> Self {
|
|
|
|
HyphaError::new(value.to_string().as_str())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<StripPrefixError> for HyphaError {
|
|
|
|
fn from(value: StripPrefixError) -> Self {
|
|
|
|
HyphaError::new(value.to_string().as_str())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<BackhandError> for HyphaError {
|
|
|
|
fn from(value: BackhandError) -> Self {
|
|
|
|
HyphaError::new(value.to_string().as_str())
|
|
|
|
}
|
|
|
|
}
|
2024-01-18 08:02:21 +00:00
|
|
|
|
|
|
|
impl From<serde_json::Error> for HyphaError {
|
|
|
|
fn from(value: serde_json::Error) -> Self {
|
|
|
|
HyphaError::new(value.to_string().as_str())
|
|
|
|
}
|
|
|
|
}
|
2024-01-18 18:16:59 +00:00
|
|
|
|
|
|
|
impl From<ureq::Error> for HyphaError {
|
|
|
|
fn from(value: ureq::Error) -> Self {
|
|
|
|
HyphaError::new(value.to_string().as_str())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<ParseIntError> for HyphaError {
|
|
|
|
fn from(value: ParseIntError) -> Self {
|
|
|
|
HyphaError::new(value.to_string().as_str())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<OciSpecError> for HyphaError {
|
|
|
|
fn from(value: OciSpecError) -> Self {
|
|
|
|
HyphaError::new(value.to_string().as_str())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<url::ParseError> for HyphaError {
|
|
|
|
fn from(value: url::ParseError) -> Self {
|
|
|
|
HyphaError::new(value.to_string().as_str())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<std::fmt::Error> for HyphaError {
|
|
|
|
fn from(value: std::fmt::Error) -> Self {
|
|
|
|
HyphaError::new(value.to_string().as_str())
|
|
|
|
}
|
|
|
|
}
|
2024-01-21 09:58:07 +00:00
|
|
|
|
|
|
|
impl From<uuid::Error> for HyphaError {
|
|
|
|
fn from(value: uuid::Error) -> Self {
|
|
|
|
HyphaError::new(value.to_string().as_str())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<XsdBusError> for HyphaError {
|
|
|
|
fn from(value: XsdBusError) -> Self {
|
|
|
|
HyphaError::new(value.to_string().as_str())
|
|
|
|
}
|
|
|
|
}
|
2024-01-22 01:21:19 +00:00
|
|
|
|
|
|
|
impl From<TableError> for HyphaError {
|
|
|
|
fn from(value: TableError) -> Self {
|
|
|
|
HyphaError::new(value.to_string().as_str())
|
|
|
|
}
|
|
|
|
}
|