Skip to main content

greentic_ext_runtime/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum RuntimeError {
5    #[error("extension '{0}' already loaded")]
6    AlreadyLoaded(String),
7
8    #[error("extension '{0}' not found")]
9    NotFound(String),
10
11    #[error(
12        "signature verification failed for extension '{extension_id}': {reason}\n\
13         hint: reinstall a signed extension (production), or rebuild ext-runtime \
14         with `--features dev-allow-unsigned` and set GREENTIC_EXT_ALLOW_UNSIGNED=1 (dev only)"
15    )]
16    SignatureInvalid {
17        extension_id: String,
18        reason: String,
19    },
20
21    #[error("contract error: {0}")]
22    Contract(#[from] greentic_extension_sdk_contract::ContractError),
23
24    #[error("wasmtime: {0}")]
25    Wasmtime(#[from] anyhow::Error),
26
27    #[error("io: {0}")]
28    Io(#[from] std::io::Error),
29
30    #[error("json: {0}")]
31    Json(#[from] serde_json::Error),
32
33    #[error("watcher: {0}")]
34    Watcher(String),
35
36    #[error("deploy extension error: {0}")]
37    Deploy(crate::types::DeployExtensionError),
38
39    #[error("permission denied: {0}")]
40    PermissionDenied(String),
41
42    /// A WIT-level `extension-error` returned by the extension itself.
43    /// Carries the variant intact so hosts can surface a stable `code`
44    /// in the response envelope — do NOT collapse into `Wasmtime`.
45    #[error("extension error ({code}): {msg}", code = .0.code(), msg = .0)]
46    Extension(crate::types::HostExtensionError),
47}