1pub type Result<T> = std::result::Result<T, Error>;
5
6#[derive(Debug, thiserror::Error)]
8pub enum Error {
9 #[error("Failed to parse component: {0}")]
11 ParseError(String),
12
13 #[error("Component validation failed: {0}")]
15 ValidationError(String),
16
17 #[error("Synthesis failed: {0}")]
19 SynthesisError(String),
20
21 #[error("Target not supported: {0}")]
23 UnsupportedTarget(String),
24
25 #[error("Unsupported instruction for target: {0}")]
27 UnsupportedInstruction(String),
28
29 #[error("Memory layout error: {0}")]
31 MemoryLayoutError(String),
32
33 #[error("Hardware protection error: {0}")]
35 HardwareProtectionError(String),
36
37 #[error("IO error: {0}")]
39 IoError(#[from] std::io::Error),
40
41 #[error("{0}")]
43 Other(String),
44}
45
46impl Error {
47 pub fn parse<S: Into<String>>(msg: S) -> Self {
49 Error::ParseError(msg.into())
50 }
51
52 pub fn validation<S: Into<String>>(msg: S) -> Self {
54 Error::ValidationError(msg.into())
55 }
56
57 pub fn synthesis<S: Into<String>>(msg: S) -> Self {
59 Error::SynthesisError(msg.into())
60 }
61}