navi_plugin_runtime/
error.rs1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum RuntimeError {
5 #[error("WASM engine error: {0}")]
6 Engine(String),
7
8 #[error("tool '{tool_name}' not found in plugin")]
9 ToolNotFound { tool_name: String },
10
11 #[error("fuel exhausted: plugin consumed all allocated fuel")]
12 FuelExhausted,
13
14 #[error("memory limit exceeded: plugin tried to allocate beyond {limit_mb} MB")]
15 MemoryLimitExceeded { limit_mb: u64 },
16
17 #[error("timeout: plugin exceeded {timeout_secs}s wall-clock limit")]
18 Timeout { timeout_secs: u64 },
19
20 #[error("output too large: {size_bytes} bytes exceeds {limit_bytes} bytes")]
21 OutputTooLarge {
22 size_bytes: usize,
23 limit_bytes: usize,
24 },
25
26 #[error("invalid input JSON: {0}")]
27 InvalidInput(String),
28
29 #[error("plugin returned error: {0}")]
30 PluginError(String),
31}
32
33impl From<wasmtime::Error> for RuntimeError {
34 fn from(err: wasmtime::Error) -> Self {
35 RuntimeError::Engine(err.to_string())
36 }
37}
38
39impl From<anyhow::Error> for RuntimeError {
40 fn from(err: anyhow::Error) -> Self {
41 RuntimeError::Engine(err.to_string())
42 }
43}