use std::{fmt, 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 fmt::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())
}
}