1use std::error;
2use std::fmt;
3
4#[derive(Debug,Clone)]
6pub enum CalcifyError {
7 LightSpeedError,
8 KeyError,
9 ParseError,
10 LengthError,
11 ObjectBranchDeserializeError,
12}
13
14impl fmt::Display for CalcifyError {
15 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
16 match *self {
17 CalcifyError::LightSpeedError => write!(f,"Velocity greater than calcify::C_LIGHT."),
18 CalcifyError::KeyError => write!(f,"Invalid Key"),
19 CalcifyError::ParseError => write!(f,"Error on parse in Deserializable."),
20 CalcifyError::LengthError => write!(f,"Invalid slice length"),
21 CalcifyError::ObjectBranchDeserializeError => write!(f,"Attempted to deserialize Object Branch."),
22 }
23 }
24}
25
26impl error::Error for CalcifyError {
27 fn description(&self) -> &str {
28 match *self {
29 CalcifyError::LightSpeedError => "Cannot have a velocity greater than calcify::C_LIGHT",
30 CalcifyError::KeyError => "Convert HashMap Option behavior to Err on bad keys",
31 CalcifyError::ParseError => "Probably a formatting error when the data was serialized, or there is a type mismatch.",
32 CalcifyError::LengthError => "Length of slice must match Vector length",
33 CalcifyError::ObjectBranchDeserializeError => "Cannot deserialize Object Branch.",
34 }
35 }
36
37 fn source(&self) -> Option<&(dyn error::Error + 'static)> {
38 None
40 }
41}