1use thiserror::Error;
2
3#[derive(Debug, Error, Clone)]
4pub enum ReplError {
5 #[error("Evaluation failed: {0}")]
6 Evaluation(String),
7 #[error("Policy parsing failed: {0}")]
8 PolicyParsing(String),
9 #[error("Lexing failed: {0}")]
10 Lexing(String),
11 #[error("Parsing failed: {0}")]
12 Parsing(String),
13 #[error("Execution failed: {0}")]
14 Execution(String),
15 #[error("Security error: {0}")]
16 Security(String),
17 #[error("Runtime error: {0}")]
18 Runtime(String),
19 #[error("IO error: {0}")]
20 Io(String),
21 #[error("JSON error: {0}")]
22 Json(String),
23 #[error("UUID error: {0}")]
24 Uuid(String),
25}
26
27impl From<std::io::Error> for ReplError {
28 fn from(error: std::io::Error) -> Self {
29 ReplError::Io(error.to_string())
30 }
31}
32
33impl From<serde_json::Error> for ReplError {
34 fn from(error: serde_json::Error) -> Self {
35 ReplError::Json(error.to_string())
36 }
37}
38
39impl From<uuid::Error> for ReplError {
40 fn from(error: uuid::Error) -> Self {
41 ReplError::Uuid(error.to_string())
42 }
43}
44
45pub type Result<T> = std::result::Result<T, ReplError>;