Skip to main content

morok_codegen/
error.rs

1//! Error types for code generation.
2
3use snafu::Snafu;
4
5pub type Result<T, E = Error> = std::result::Result<T, E>;
6
7/// Errors that can occur during code generation.
8#[derive(Debug, Snafu)]
9#[snafu(visibility(pub))]
10pub enum Error {
11    /// Unsupported operation in the UOp graph.
12    #[snafu(display("Unsupported operation: {op:?}"))]
13    UnsupportedOp { op: String },
14
15    /// Invalid UOp graph structure.
16    #[snafu(display("Invalid UOp graph: {reason}"))]
17    InvalidGraph { reason: String },
18
19    /// Type error during code generation.
20    #[snafu(display("Type error: {reason}"))]
21    TypeError { reason: String },
22
23    /// LLVM-specific error.
24    #[snafu(display("LLVM error: {reason}"))]
25    LlvmError { reason: String },
26
27    /// Missing required information.
28    #[snafu(display("Missing {what}"))]
29    Missing { what: String },
30
31    /// Invalid configuration or parameters.
32    #[snafu(display("Invalid configuration: {reason}"))]
33    InvalidConfig { reason: String },
34
35    /// MLIR-specific error.
36    #[snafu(display("MLIR error: {reason}"))]
37    MlirError { reason: String },
38
39    /// Error from IR layer.
40    #[snafu(display("IR error: {source}"))]
41    IrError {
42        #[snafu(source)]
43        source: morok_ir::Error,
44    },
45}