herolib_sid/
error.rs

1//! Error types for SmartID operations
2
3use super::base36::DecodeError;
4use thiserror::Error;
5
6/// Errors that can occur during SmartID operations
7#[derive(Debug, Error)]
8pub enum SidError {
9    /// Contributor ID exceeds maximum (998)
10    #[error("contributor id {0} exceeds maximum 998")]
11    ContributorIdTooLarge(u16),
12
13    /// Space has reached maximum contributors (999)
14    #[error("space has reached maximum contributors (999)")]
15    MaxContributorsReached,
16
17    /// Invalid SmartID format
18    #[error("invalid sid format: {0}")]
19    InvalidFormat(String),
20
21    /// Base36 decoding failed
22    #[error("base36 decode error: {0}")]
23    DecodeError(#[from] DecodeError),
24
25    /// Global ID overflow (exceeded 6-char capacity)
26    #[error("global id overflow: value {0} exceeds 6-char capacity")]
27    GlobalIdOverflow(u64),
28
29    /// Contributor not registered
30    #[error("contributor {0} not registered - call register_contributor first")]
31    ContributorNotRegistered(u16),
32
33    /// Invalid counter file format
34    #[error("invalid counter file for contributor {0}")]
35    InvalidCounterFile(u16),
36
37    /// Invalid config file format
38    #[error("invalid config file: {0}")]
39    InvalidConfigFile(String),
40
41    /// Invalid name format (not name-fixed)
42    #[error("invalid name format: {0}")]
43    InvalidName(String),
44
45    /// I/O error during storage operations
46    #[error("io error: {0}")]
47    IoError(#[from] std::io::Error),
48
49    /// Serialization error
50    #[error("serialization error: {0}")]
51    SerializationError(String),
52
53    /// Object not found
54    #[error("object not found: {0}")]
55    NotFound(String),
56
57    /// Storage backend error
58    #[error("storage error: {0}")]
59    StorageError(String),
60}
61
62pub type Result<T> = std::result::Result<T, SidError>;