rusty-beads 0.1.0

Git-backed graph issue tracker for AI coding agents - a Rust implementation with context store, dependency tracking, and semantic compaction
Documentation
//! Storage error types.

use thiserror::Error;

/// Errors that can occur during storage operations.
#[derive(Debug, Error)]
pub enum StorageError {
    /// Issue not found.
    #[error("issue not found: {0}")]
    NotFound(String),

    /// Issue already exists.
    #[error("issue already exists: {0}")]
    AlreadyExists(String),

    /// Dependency would create a cycle.
    #[error("dependency would create a cycle from {from} to {to}")]
    CycleDetected { from: String, to: String },

    /// Invalid dependency - one or both issues don't exist.
    #[error("invalid dependency: {0}")]
    InvalidDependency(String),

    /// Database error.
    #[error("database error: {0}")]
    Database(#[from] rusqlite::Error),

    /// Serialization error.
    #[error("serialization error: {0}")]
    Serialization(#[from] serde_json::Error),

    /// IO error.
    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),

    /// Transaction error.
    #[error("transaction error: {0}")]
    Transaction(String),

    /// Validation error.
    #[error("validation error: {0}")]
    Validation(String),

    /// Storage is closed.
    #[error("storage is closed")]
    Closed,

    /// Other error.
    #[error("{0}")]
    Other(String),
}

impl StorageError {
    /// Create a validation error.
    pub fn validation(msg: impl Into<String>) -> Self {
        StorageError::Validation(msg.into())
    }

    /// Create an "other" error.
    pub fn other(msg: impl Into<String>) -> Self {
        StorageError::Other(msg.into())
    }
}