Skip to main content

stygian_plugin/
error.rs

1//! Error types for stygian-plugin
2
3use thiserror::Error;
4
5/// Result type for stygian-plugin operations
6pub type Result<T> = std::result::Result<T, PluginError>;
7
8/// Errors that can occur during plugin operations
9#[derive(Debug, Error)]
10pub enum PluginError {
11    /// Template not found by ID
12    #[error("template not found: {0}")]
13    TemplateNotFound(String),
14
15    /// Template validation failed
16    #[error("template validation failed: {0}")]
17    TemplateValidationError(String),
18
19    /// Selector evaluation failed
20    #[error("selector evaluation failed: {selector}, reason: {reason}")]
21    SelectorError { selector: String, reason: String },
22
23    /// Extraction failed
24    #[error("extraction failed: {0}")]
25    ExtractionError(String),
26
27    /// Idempotency key already processed
28    #[error("extraction already completed with idempotency key: {0}")]
29    IdempotencyDuplicate(String),
30
31    /// Idempotency store error
32    #[error("idempotency store error: {0}")]
33    IdempotencyStoreError(String),
34
35    /// Template storage error
36    #[error("template storage error: {0}")]
37    StorageError(String),
38
39    /// Serialization error
40    #[error("serialization error: {0}")]
41    SerializationError(#[from] serde_json::Error),
42
43    /// IO error
44    #[error("io error: {0}")]
45    IoError(#[from] std::io::Error),
46
47    /// Timeout occurred
48    #[error("timeout occurred")]
49    Timeout,
50
51    /// Invalid transformation configuration
52    #[error("invalid transformation: {0}")]
53    InvalidTransformation(String),
54
55    /// Schema validation failed
56    #[error("schema validation failed: {0}")]
57    SchemaValidationError(String),
58
59    /// Generic plugin error
60    #[error("{0}")]
61    Other(String),
62}