use std::fmt::Debug;
use crate::blocks::CreateTipsetError;
use cid::Error as CidErr;
use fil_actors_shared::fvm_ipld_amt::Error as AmtErr;
use fvm_ipld_encoding::Error as EncErr;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("Invalid tipset: {0}")]
UndefinedKey(String),
#[error("{0} not found")]
NotFound(String),
#[error(transparent)]
Blockchain(#[from] CreateTipsetError),
#[error("{0}")]
Encoding(String),
#[error(transparent)]
Cid(#[from] CidErr),
#[error("State error: {0}")]
State(String),
#[error("{0}")]
Other(String),
}
impl From<EncErr> for Error {
fn from(e: EncErr) -> Error {
Error::Encoding(e.to_string())
}
}
impl From<AmtErr> for Error {
fn from(e: AmtErr) -> Error {
Error::State(e.to_string())
}
}
impl From<String> for Error {
fn from(e: String) -> Self {
Error::Other(e)
}
}
impl From<anyhow::Error> for Error {
fn from(e: anyhow::Error) -> Self {
Error::Other(e.to_string())
}
}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Self {
Error::Other(e.to_string())
}
}
impl<T> From<flume::SendError<T>> for Error {
fn from(e: flume::SendError<T>) -> Self {
Error::Other(e.to_string())
}
}