use std::ops::Deref;
use thiserror::Error;
#[derive(Debug, Error)]
#[error("argument extraction failed: {0:?}")]
pub struct ExtractionError(#[from] anyhow::Error);
#[derive(Debug, Error)]
#[error("serialization error: {0:?}")]
pub struct SerializationError(#[from] serde_json::Error);
#[derive(Debug, Error)]
#[error("internal error, this may be a bug: {0:?}")]
pub struct InternalError(#[from] anyhow::Error);
#[derive(Debug, Error)]
#[error("method expansion failed: {0:?}")]
pub struct MethodError(Box<dyn std::error::Error + Send + Sync>);
impl MethodError {
pub fn new<E: std::error::Error + Send + Sync + 'static>(err: E) -> Self {
Self(Box::new(err))
}
}
#[derive(Debug, Error)]
#[error(transparent)]
pub struct IOError(Box<dyn std::error::Error + Send + Sync>);
impl IOError {
pub fn new<E: std::error::Error + Send + Sync + 'static>(err: E) -> Self {
Self(Box::new(err))
}
}
impl Deref for IOError {
type Target = Box<dyn std::error::Error + Send + Sync>;
fn deref(&self) -> &Self::Target {
&self.0
}
}