Skip to main content

homecore_plugins/
error.rs

1//! `PluginError` — typed error enum for the homecore-plugins crate.
2
3use thiserror::Error;
4
5/// Errors produced by the HOMECORE plugin system.
6#[derive(Debug, Error)]
7pub enum PluginError {
8    /// The plugin manifest JSON is missing required fields or is malformed.
9    #[error("invalid manifest: {0}")]
10    InvalidManifest(String),
11
12    /// A plugin with this ID is already loaded in the registry.
13    #[error("plugin already loaded: {0}")]
14    AlreadyLoaded(String),
15
16    /// No plugin with this ID is loaded in the registry.
17    #[error("plugin not found: {0}")]
18    NotFound(String),
19
20    /// The plugin runtime failed to spawn or execute the plugin.
21    #[error("runtime error: {0}")]
22    RuntimeError(String),
23
24    /// Plugin discovery or filesystem layout is invalid.
25    #[error("plugin discovery failed: {0}")]
26    Discovery(String),
27
28    /// A configured manifest, module, or ABI payload exceeds its limit.
29    #[error("plugin resource limit exceeded: {0}")]
30    ResourceLimit(String),
31
32    /// The plugin's `setup` hook returned an error.
33    #[error("plugin setup failed: {0}")]
34    SetupFailed(String),
35
36    /// The plugin failed signature/integrity verification (ADR-162 P4):
37    /// hash mismatch, bad signature, untrusted publisher, or unsigned
38    /// module under a non-dev trust policy.
39    #[error("plugin signature rejected: {0}")]
40    SignatureRejected(String),
41
42    /// A plugin attempted a host call (e.g. `hc_state_set`) on an entity
43    /// it did not declare in `homecore_permissions` (ADR-162 P5 authority
44    /// isolation).
45    #[error("plugin permission denied: {0}")]
46    PermissionDenied(String),
47
48    /// The plugin's `unload` hook returned an error.
49    #[error("plugin unload failed: {0}")]
50    UnloadFailed(String),
51
52    /// IO error (manifest file not found, WASM binary missing, etc.).
53    #[error("io error: {0}")]
54    Io(#[from] std::io::Error),
55}