Skip to main content

pot_o_core/
error.rs

1//! Error types for PoT-O core operations.
2
3use thiserror::Error;
4
5/// Errors that can occur in PoT-O validator and related crates.
6#[derive(Error, Debug)]
7pub enum TribeError {
8    /// Invalid operation or state.
9    #[error("Invalid operation: {0}")]
10    InvalidOperation(String),
11
12    /// Proof verification failed.
13    #[error("Proof validation failed: {0}")]
14    ProofValidationFailed(String),
15
16    /// Tensor or MML operation failed.
17    #[error("Tensor operation error: {0}")]
18    TensorError(String),
19
20    /// Cross-chain or bridge operation failed.
21    #[error("Chain bridge error: {0}")]
22    ChainBridgeError(String),
23
24    /// Network or RPC error.
25    #[error("Network error: {0}")]
26    NetworkError(String),
27
28    /// Invalid or missing configuration.
29    #[error("Configuration error: {0}")]
30    ConfigError(String),
31
32    /// Device or protocol error.
33    #[error("Device protocol error: {0}")]
34    DeviceError(String),
35
36    /// Serialization or deserialization failed.
37    #[error("Serialization error: {0}")]
38    SerializationError(String),
39
40    /// I/O error (e.g. file or network).
41    #[error("IO error: {0}")]
42    IoError(#[from] std::io::Error),
43
44    /// Tensor network operation failed or reached capacity
45    #[error("Tensor network error: {0}")]
46    TensorNetworkError(String),
47
48    /// Tensor network is at maximum capacity
49    #[error("Tensor network is full: cannot add more vertices/edges")]
50    TensorNetworkFull,
51}
52
53/// Result type alias using [`TribeError`].
54pub type TribeResult<T> = Result<T, TribeError>;