Skip to main content

shape_jit/
error.rs

1//! JIT compiler error types.
2
3/// Errors produced by the JIT compiler.
4#[derive(Debug, thiserror::Error)]
5pub enum JitError {
6    /// Cranelift ISA or settings configuration failed.
7    #[error("JIT setup: {0}")]
8    Setup(String),
9
10    /// Cranelift compilation or module error.
11    #[error("JIT compilation: {0}")]
12    Compilation(String),
13
14    /// An opcode or bytecode construct is not supported by the JIT.
15    #[error("unsupported opcode: {0}")]
16    UnsupportedOpcode(String),
17
18    /// Translation from bytecode to Cranelift IR failed.
19    #[error("JIT translation: {0}")]
20    Translation(String),
21
22    /// A function referenced by the bytecode was not found.
23    #[error("function not found: {0}")]
24    FunctionNotFound(String),
25
26    /// Type error during JIT compilation.
27    #[error("JIT type error: {0}")]
28    TypeError(String),
29}
30
31impl From<String> for JitError {
32    fn from(s: String) -> Self {
33        JitError::Compilation(s)
34    }
35}
36
37impl From<JitError> for String {
38    fn from(e: JitError) -> Self {
39        e.to_string()
40    }
41}