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("{0}")]
17 Other(String),
18}
19
20impl Error {
21 pub fn state(e: impl Display) -> Self {
22 Self::State(e.to_string())
23 }
24
25 pub fn other(e: impl Display) -> Self {
26 Self::Other(e.to_string())
27 }
28}
29
30impl From<String> for Error {
31 fn from(e: String) -> Self {
32 Error::Other(e)
33 }
34}
35
36impl From<anyhow::Error> for Error {
37 fn from(e: anyhow::Error) -> Self {
38 Error::other(e)
39 }
40}
41
42impl From<JoinError> for Error {
43 fn from(e: JoinError) -> Self {
44 Error::Other(format!("failed joining on tokio task: {e}"))
45 }
46}