frclib_core/value/
error.rs

1use thiserror::Error;
2
3use super::FrcType;
4
5#[derive(Debug, Clone, Copy)]
6pub enum CastErrorReason {
7    Type,
8    Overflow,
9    Underflow,
10    Deserialization,
11}
12
13/// An error that occurs when casting between [``FrcValue``](super::FrcValue) and other types
14#[allow(missing_docs)]
15#[derive(Debug, Clone, Copy, Error)]
16pub enum FrcValueCastError {
17    #[error("Could not cast {0} variant to {1} type ({2:?})")]
18    InvalidCastTo(FrcType, &'static str, CastErrorReason),
19    #[error("Could not cast {0} type to {1} variant ({2:?})")]
20    InvalidCastFrom(&'static str, FrcType, CastErrorReason),
21    #[error("Could not represent the casted data as an FrcValue")]
22    UnrepresentableCast,
23}