1use std::fmt;
4
5#[derive(Clone, Debug, Eq, PartialEq)]
7pub enum BlockCodegenError {
8 TopSelection(String),
10 InvalidBlock(String),
12 Unsupported(String),
14 NotPipeline(String),
16 Emission(String),
18}
19
20impl fmt::Display for BlockCodegenError {
21 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
22 match self {
23 Self::TopSelection(message)
24 | Self::InvalidBlock(message)
25 | Self::Unsupported(message)
26 | Self::NotPipeline(message)
27 | Self::Emission(message) => formatter.write_str(message),
28 }
29 }
30}
31
32impl std::error::Error for BlockCodegenError {}
33
34impl From<xlsynth_vast::VastError> for BlockCodegenError {
35 fn from(error: xlsynth_vast::VastError) -> Self {
36 Self::Emission(error.to_string())
37 }
38}
39
40impl From<xlsynth::XlsynthError> for BlockCodegenError {
41 fn from(error: xlsynth::XlsynthError) -> Self {
42 Self::Emission(error.to_string())
43 }
44}
45
46impl From<xlsynth_pir::ValueError> for BlockCodegenError {
47 fn from(error: xlsynth_pir::ValueError) -> Self {
48 Self::Emission(error.to_string())
49 }
50}