orbis_plugin_api/
error.rs

1//! Error types for plugin development.
2
3/// Plugin API error type.
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6    /// Invalid plugin configuration.
7    #[error("Invalid plugin: {0}")]
8    InvalidPlugin(String),
9
10    /// Invalid manifest.
11    #[error("Invalid manifest: {0}")]
12    InvalidManifest(String),
13
14    /// Invalid UI schema.
15    #[error("Invalid UI schema: {0}")]
16    InvalidSchema(String),
17
18    /// Validation error.
19    #[error("Validation error: {0}")]
20    Validation(String),
21
22    /// Serialization error.
23    #[error("Serialization error: {0}")]
24    Serialization(#[from] serde_json::Error),
25}
26
27impl Error {
28    /// Create a new plugin error.
29    #[must_use]
30    pub fn plugin<S: Into<String>>(msg: S) -> Self {
31        Self::InvalidPlugin(msg.into())
32    }
33
34    /// Create a new manifest error.
35    #[must_use]
36    pub fn manifest<S: Into<String>>(msg: S) -> Self {
37        Self::InvalidManifest(msg.into())
38    }
39
40    /// Create a new schema error.
41    #[must_use]
42    pub fn schema<S: Into<String>>(msg: S) -> Self {
43        Self::InvalidSchema(msg.into())
44    }
45
46    /// Create a new validation error.
47    #[must_use]
48    pub fn validation<S: Into<String>>(msg: S) -> Self {
49        Self::Validation(msg.into())
50    }
51}
52
53/// Result type for plugin operations.
54pub type Result<T> = std::result::Result<T, Error>;