1use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum VexyError {
7 #[error("I/O error: {0}")]
8 Io(#[from] std::io::Error),
9
10 #[error("XML parsing error: {0}")]
11 Parse(#[from] crate::parser::error::ParseError),
12
13 #[error("Plugin '{0}' failed: {1}")]
14 Plugin(String, String),
15
16 #[error("Invalid configuration: {0}")]
17 Config(String),
18
19 #[error("Regex error: {0}")]
20 Regex(String),
21
22 #[error("Memory budget exceeded: {0}")]
23 Memory(#[from] crate::optimizer::memory::MemoryError),
24
25 #[error("{0}")]
26 General(String),
27}
28
29impl From<String> for VexyError {
30 fn from(s: String) -> Self {
31 VexyError::General(s)
32 }
33}
34
35impl From<&str> for VexyError {
36 fn from(s: &str) -> Self {
37 VexyError::General(s.to_string())
38 }
39}
40
41impl From<anyhow::Error> for VexyError {
42 fn from(err: anyhow::Error) -> Self {
43 VexyError::General(err.to_string())
44 }
45}
46
47impl From<regex::Error> for VexyError {
48 fn from(err: regex::Error) -> Self {
49 VexyError::Regex(err.to_string())
50 }
51}
52
53impl From<std::fmt::Error> for VexyError {
54 fn from(err: std::fmt::Error) -> Self {
55 VexyError::General(err.to_string())
56 }
57}