Skip to main content

crate_seq_ledger/
error.rs

1//! Error type for ledger I/O and state-machine operations.
2
3/// All errors that can occur in crate-seq-ledger operations.
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6    /// Filesystem I/O failure.
7    #[error("I/O error: {0}")]
8    Io(#[from] std::io::Error),
9    /// TOML deserialization failure.
10    #[error("TOML deserialize: {0}")]
11    Deserialize(#[from] toml_edit::de::Error),
12    /// TOML serialization failure.
13    #[error("TOML serialize: {0}")]
14    Serialize(#[from] toml_edit::ser::Error),
15    /// No entry exists for the requested version.
16    #[error("version {0} not found in ledger")]
17    VersionNotFound(semver::Version),
18    /// The requested state transition is not permitted.
19    #[error("invalid state transition for {0}: {1} → {2}")]
20    InvalidTransition(semver::Version, &'static str, &'static str),
21}