1#[derive(Debug)]
8pub enum CodeGenError {
9 Logic(String),
11 Format(std::fmt::Error),
13}
14
15impl std::fmt::Display for CodeGenError {
16 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17 match self {
18 CodeGenError::Logic(s) => write!(f, "{}", s),
19 CodeGenError::Format(e) => write!(f, "IR generation error: {}", e),
20 }
21 }
22}
23
24impl std::error::Error for CodeGenError {}
25
26impl From<String> for CodeGenError {
27 fn from(s: String) -> Self {
28 CodeGenError::Logic(s)
29 }
30}
31
32impl From<std::fmt::Error> for CodeGenError {
33 fn from(e: std::fmt::Error) -> Self {
34 CodeGenError::Format(e)
35 }
36}