Skip to main content

svod_runtime/
error.rs

1//! Error types for runtime execution.
2
3use snafu::Snafu;
4
5/// Result type for runtime operations.
6pub type Result<T, E = Error> = std::result::Result<T, E>;
7
8/// Errors that can occur during runtime execution.
9#[derive(Debug, Snafu)]
10#[snafu(visibility(pub))]
11pub enum Error {
12    /// Codegen error occurred.
13    #[snafu(display("Codegen error: {source}"))]
14    Codegen { source: svod_codegen::Error },
15
16    /// JIT compilation failed.
17    #[snafu(display("JIT compilation failed: {reason}"))]
18    JitCompilation { reason: String },
19
20    /// Function not found in module.
21    #[snafu(display("Function '{name}' not found in module"))]
22    FunctionNotFound { name: String },
23
24    /// Buffer allocation failed.
25    #[snafu(display("Buffer allocation failed: {reason}"))]
26    BufferAllocation { reason: String },
27
28    /// Invalid buffer size.
29    #[snafu(display("Invalid buffer size: {size}"))]
30    InvalidBufferSize { size: usize },
31
32    /// Execution error.
33    #[snafu(display("Execution error: {reason}"))]
34    Execution { reason: String },
35
36    /// LLVM error.
37    #[snafu(display("LLVM error: {reason}"))]
38    LlvmError { reason: String },
39
40    /// Unsupported device type.
41    #[snafu(display("Unsupported device type: {device}"))]
42    UnsupportedDevice { device: String },
43
44    /// Reserved-but-unsupported runtime feature.
45    #[snafu(display("Unsupported runtime feature {kind}: {reason}"))]
46    Unsupported { kind: String, reason: String },
47
48    /// Device error (from svod_device crate).
49    #[snafu(display("Device error: {source}"))]
50    Device { source: svod_device::Error },
51}
52
53impl From<svod_device::Error> for Error {
54    fn from(source: svod_device::Error) -> Self {
55        Error::Device { source }
56    }
57}