1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use std::{fmt, fmt::Formatter, io};
use crate::algebra::error::FnError;
#[derive(Debug, Clone, PartialEq)]
pub enum Error {
Fn(FnError),
Term(String),
Put(String),
IO(String),
Agent(String),
Stream(String),
Extraction(),
SecurityClaim(&'static str),
}
impl std::error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Error::Fn(err) => write!(f, "error executing a function symbol: {}", err),
Error::Term(err) => write!(f, "error evaluating a term: {}", err),
Error::Put(err) => write!(f, "error in openssl: {}", err),
Error::IO(err) => write!(
f,
"error in io of openssl (this should not happen): {}",
err
),
Error::Agent(err) => write!(f, "error regarding an agent: {}", err),
Error::Stream(err) => write!(f, "error in the stream: {}", err),
Error::Extraction() => write!(f, "error while extracting variable",),
Error::SecurityClaim(msg) => write!(
f,
"error because a security violation occurred. msg: {}",
msg
),
}
}
}
impl From<FnError> for Error {
fn from(err: FnError) -> Self {
Error::Fn(err)
}
}
impl From<io::Error> for Error {
fn from(err: io::Error) -> Self {
Error::IO(err.to_string())
}
}