use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Error, Debug)]
pub enum Error {
#[error("infrastructure error: {0}")]
Infrastructure(#[from] Box<dyn std::error::Error + Send + Sync>),
#[error("failed to decode payload: {0}")]
PayloadDecode(String),
#[error("resource '{id}' of type '{resource_type}' not found")]
ResourceNotFound { resource_type: String, id: String },
#[error("unrecognized or unauthorized signet: {0}")]
UnknownSignet(String),
#[error("invalid vigil state for operation: {0}")]
InvalidVigilState(String),
#[error("request timed out after {duration:?}")]
RequestTimeout { duration: std::time::Duration },
#[error("invalid identifier for type '{0}': cannot be empty")]
InvalidIdentifier(String),
#[error("an unrecoverable error occurred: {0}")]
Unrecoverable(String),
}
impl Error {
pub fn from_infra<E>(err: E) -> Self
where
E: std::error::Error + Send + Sync + 'static,
{
Error::Infrastructure(Box::new(err))
}
}