forest/state_manager/
errors.rs1use std::fmt::{Debug, Display};
5
6use thiserror::Error;
7use tokio::task::JoinError;
8
9#[derive(Debug, PartialEq, Error)]
11pub enum Error {
12 #[error("{0}")]
14 State(String),
15 #[error("refusing explicit call due to state fork at epoch")]
17 ExpensiveFork,
18 #[error("{0}")]
20 Other(String),
21}
22
23impl Error {
24 pub fn state(e: impl Display) -> Self {
25 Self::State(e.to_string())
26 }
27
28 pub fn other(e: impl Display) -> Self {
29 Self::Other(e.to_string())
30 }
31}
32
33impl From<String> for Error {
34 fn from(e: String) -> Self {
35 Error::Other(e)
36 }
37}
38
39impl From<anyhow::Error> for Error {
40 fn from(e: anyhow::Error) -> Self {
41 Error::other(format!("{e:#}"))
42 }
43}
44
45impl From<JoinError> for Error {
46 fn from(e: JoinError) -> Self {
47 Error::Other(format!("failed joining on tokio task: {e}"))
48 }
49}