//! Composite error type for the substrate composition layer.

/// Errors surfaced by `Substrate`.
#[derive(Debug, thiserror::Error)]
pub enum Error {
    /// Filesystem IO failure.
    #[error("io: {0}")]
    Io(#[from] std::io::Error),
    /// Blob store layer (L1) error.
    #[error("blobs: {0}")]
    Blobs(#[from] ontoref_blobs::Error),
    /// Op log layer (L2) error.
    #[error("oplog: {0}")]
    OpLog(#[from] ontoref_oplog::Error),
    /// Triple store layer (L3) error.
    #[error("triples: {0}")]
    Triples(#[from] ontoref_triples::Error),
    /// Commit layer (L4) error.
    #[error("commit: {0}")]
    Commit(#[from] ontoref_commit::Error),
    /// Query/subscription layer (L5) error.
    #[error("query: {0}")]
    Query(#[from] ontoref_query::Error),
    /// Canonical encoding error from the L0 types crate.
    #[error("canonical: {0}")]
    Canonical(#[from] ontoref_types::Error),
}

/// Convenience alias.
pub type Result<T> = std::result::Result<T, Error>;
