Skip to main content

orcs_lua/
error.rs

1//! Error types for Lua component operations.
2
3use thiserror::Error;
4
5/// Errors that can occur in Lua component operations.
6#[derive(Debug, Error)]
7pub enum LuaError {
8    /// Lua runtime error.
9    #[error("lua error: {0}")]
10    Runtime(#[from] mlua::Error),
11
12    /// Script file not found.
13    #[error("script not found: {0}")]
14    ScriptNotFound(String),
15
16    /// Invalid script format.
17    #[error("invalid script: {0}")]
18    InvalidScript(String),
19
20    /// Missing required callback.
21    #[error("missing callback: {0}")]
22    MissingCallback(String),
23
24    /// Type conversion error.
25    #[error("type error: {0}")]
26    TypeError(String),
27
28    /// Component initialization failed.
29    #[error("init failed: {0}")]
30    InitFailed(String),
31}
32
33impl From<LuaError> for orcs_component::ComponentError {
34    fn from(err: LuaError) -> Self {
35        orcs_component::ComponentError::ExecutionFailed(err.to_string())
36    }
37}