1pub type Result<T = ()> = core::result::Result<T, crate::Error>;
8
9#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, strum::EnumIs, thiserror::Error)]
10#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
11pub enum StateError {
12 #[error("Invalid State: {0}")]
13 InvalidState(String),
14 #[error("State Not Found")]
15 StateNotFound,
16}
17
18#[derive(
19 Clone,
20 Debug,
21 Eq,
22 Hash,
23 Ord,
24 PartialEq,
25 PartialOrd,
26 scsys_derive::VariantConstructors,
27 strum::EnumDiscriminants,
28 strum::EnumIs,
29 thiserror::Error,
30)]
31#[strum_discriminants(derive(Hash, Ord, PartialOrd))]
32#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
33pub enum Error {
34 #[error("[Execution Error] {0}")]
35 ExecutionError(String),
36 #[error("[Index Error] Out of Bounds: {index} is out of bounds for a length of {len}")]
37 IndexOutOfBounds { index: usize, len: usize },
38 #[error("[Runtime Error] {0}")]
39 RuntimeError(String),
40 #[error("[State Error] {0}")]
41 StateError(#[from] StateError),
42 #[error("[Transformation Error]: {0}")]
43 TransformationError(String),
44 #[error("[Type Error] {0}")]
45 TypeError(String),
46 #[error("[Unknown Error] {0}")]
47 Unknown(String),
48}
49
50impl From<Box<dyn std::error::Error>> for Error {
51 fn from(err: Box<dyn std::error::Error>) -> Self {
52 Error::Unknown(err.to_string())
53 }
54}
55
56impl From<&str> for Error {
57 fn from(err: &str) -> Self {
58 Error::Unknown(err.to_string())
59 }
60}
61
62impl From<String> for Error {
63 fn from(err: String) -> Self {
64 Error::Unknown(err)
65 }
66}