type-bridge-orm 1.5.2

Async ORM for TypeDB built on type-bridge-core-lib
Documentation
//! Unified error types for the ORM crate.

use thiserror::Error;

/// Unified error type for the ORM crate.
#[derive(Debug, Error)]
pub enum OrmError {
    /// The detected TypeDB driver or server version lies outside the supported
    /// window, or the driver and server speak different protocol bands.
    ///
    /// The inner [`type_bridge_core_lib::version::VersionError`] message is
    /// preserved verbatim — including version numbers and remediation text —
    /// so no information is lost at the ORM boundary.
    #[error("Unsupported version: {0}")]
    UnsupportedVersion(#[from] type_bridge_core_lib::version::VersionError),

    /// Connection to TypeDB failed.
    #[error("Connection error: {0}")]
    Connection(String),

    /// Query execution failed.
    #[error("Query execution error: {0}")]
    QueryExecution(String),

    /// Transaction already committed or rolled back.
    #[error("Transaction error: {0}")]
    Transaction(String),

    /// Failed to hydrate query results into Rust structs.
    #[error("Hydration error for type '{type_name}': {message}")]
    Hydration {
        /// The entity type name that failed hydration.
        type_name: String,
        /// A description of what went wrong.
        message: String,
    },

    /// Entity not found.
    #[error("Entity not found: {0}")]
    NotFound(String),

    /// Invalid filter specification.
    #[error("Invalid filter: {0}")]
    InvalidFilter(String),

    /// Runtime descriptor validation failed.
    #[error("Descriptor validation error for type '{type_name}': {message}")]
    DescriptorValidation {
        /// The descriptor type name, or `<registry>` for registry state errors.
        type_name: String,
        /// A description of what went wrong.
        message: String,
    },

    /// Runtime descriptor conflicts with an existing registration or expected kind.
    #[error("Descriptor conflict for type '{type_name}': {message}")]
    DescriptorConflict {
        /// The descriptor type name.
        type_name: String,
        /// A description of the conflict.
        message: String,
    },

    /// Runtime descriptor was not registered.
    #[error("Descriptor not found for type '{0}'")]
    DescriptorNotFound(String),

    /// AST compilation failed.
    #[error("Compilation error: {0}")]
    Compilation(String),

    /// Schema management error.
    #[error("Schema error: {0}")]
    Schema(#[from] crate::schema::SchemaError),

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

    /// A lifecycle hook rejected or failed the operation.
    #[error("Hook error: {0}")]
    Hook(#[from] crate::hooks::HookError),
}

/// Convenience Result alias for ORM operations.
pub type Result<T> = std::result::Result<T, OrmError>;