Skip to main content

contextvm_sdk/core/
error.rs

1//! Error types for the ContextVM SDK
2
3/// Result type alias for ContextVM operations.
4pub type Result<T> = std::result::Result<T, Error>;
5
6/// Errors that can occur during ContextVM operations.
7#[derive(Debug, thiserror::Error)]
8pub enum Error {
9    /// Transport-level error (relay connection, publishing, subscription)
10    #[error("Transport error: {0}")]
11    Transport(String),
12
13    /// NIP-44 encryption error
14    #[error("Encryption error: {0}")]
15    Encryption(String),
16
17    /// NIP-44 decryption error
18    #[error("Decryption error: {0}")]
19    Decryption(String),
20
21    /// Request timed out waiting for response
22    #[error("Request timed out")]
23    Timeout,
24
25    /// Message validation error (size, schema)
26    #[error("Validation error: {0}")]
27    Validation(String),
28
29    /// Unauthorized request (pubkey not in allowlist)
30    #[error("Unauthorized: {0}")]
31    Unauthorized(String),
32
33    /// Serialization/deserialization error
34    #[error("Serialization error: {0}")]
35    Serialization(#[from] serde_json::Error),
36
37    /// Generic error
38    #[error("{0}")]
39    Other(String),
40}