xynthe 0.1.0

A unified orchestration framework for autonomous intelligence with temporal continuity
Documentation
//! Error types and result aliases for Xynthe

use thiserror::Error;

/// Main error type for Xynthe operations
#[derive(Error, Debug)]
pub enum Error {
    /// Error when a required precondition is not met
    #[error("Precondition not satisfied: {0}")]
    PreconditionNotMet(String),

    /// Error when a capability execution fails
    #[error("Capability execution failed: {0}")]
    CapabilityExecutionFailed(String),

    /// Error when a thought stream operation fails
    #[error("Thought stream error: {0}")]
    ThoughtStreamError(String),

    /// Error when context fabric operation fails
    #[error("Context fabric error: {0}")]
    ContextFabricError(String),

    /// Error when executing a trace fails
    #[error("Trace execution error: {0}")]
    ExecutionError(String),

    /// Error when serialization/deserialization fails
    #[error("Serialization error: {0}")]
    SerializationError(#[from] serde_json::Error),

    /// Error when an invalid state is encountered
    #[error("Invalid state: {0}")]
    InvalidState(String),

    /// Error when a resource is not found
    #[error("Resource not found: {0}")]
    NotFound(String),

    /// Error when operation times out
    #[error("Operation timed out: {0}")]
    Timeout(String),

    /// Generic error for other failures
    #[error("{0}")]
    Other(String),
}

/// Result type alias using Xynthe's Error
pub type Result<T> = std::result::Result<T, Error>;

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_error_display() {
        let err = Error::PreconditionNotMet("test".into());
        assert_eq!(err.to_string(), "Precondition not satisfied: test");
    }
}