forest/state_manager/
errors.rs1use std::fmt::{Debug, Display};
5
6use crate::shim::clock::ChainEpoch;
7use thiserror::Error;
8use tokio::task::JoinError;
9
10#[derive(Debug, PartialEq, Error)]
12pub enum Error {
13 #[error("{0}")]
15 State(String),
16 #[error(
18 "required historical state unavailable: refusing explicit call due to state fork at epoch {epoch}"
19 )]
20 ExpensiveFork { epoch: ChainEpoch },
21 #[error("{0}: sender validation failed")]
24 SenderValidationFailed(String),
25 #[error("{0}")]
27 Other(String),
28}
29
30impl Error {
31 pub fn state(e: impl Display) -> Self {
32 Self::State(e.to_string())
33 }
34
35 pub fn other(e: impl Display) -> Self {
36 Self::Other(e.to_string())
37 }
38}
39
40impl From<String> for Error {
41 fn from(e: String) -> Self {
42 Error::Other(e)
43 }
44}
45
46impl From<anyhow::Error> for Error {
47 fn from(e: anyhow::Error) -> Self {
48 Error::other(format!("{e:#}"))
49 }
50}
51
52impl From<JoinError> for Error {
53 fn from(e: JoinError) -> Self {
54 Error::Other(format!("failed joining on tokio task: {e}"))
55 }
56}