skybase 0.1.11

The Open-Source Backend & Developer Platform for the AT Protocol (Firebase for ATProto, powered by skyauth)
Documentation
//! Strongly-typed error definitions for `skybase`.

use thiserror::Error;

/// Root error type encompassing all failure modes across the `skybase` library.
#[derive(Debug, Error)]
pub enum SkybaseError {
    /// Failure originating from the underlying `skyauth` authentication engine.
    #[error("Authentication error: {0}")]
    Auth(#[from] skyauth::error::AtprotoOAuthError),

    /// Failure executing XRPC or repository operations against a PDS.
    #[error("Repository error: {0}")]
    Repo(String),

    /// Failure during micro-AppView indexing or query execution.
    #[error("Index error: {0}")]
    Index(String),

    /// Failure during blob or media upload/download processing.
    #[error("Storage error: {0}")]
    Storage(String),

    /// Failure in reactive event streaming or subscription handling.
    #[error("Event stream error: {0}")]
    Event(String),

    /// Failure communicating with the ATProto Chat (`chat.bsky.convo.*`) service.
    #[error("Chat/DM service error: {0}")]
    Chat(String),

    /// Invalid configuration supplied to Skybase engine or client.
    #[error("Configuration error: {0}")]
    Config(String),

    /// Networking or transport failure.
    #[error("Network error: {0}")]
    Network(#[from] reqwest::Error),

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

    /// Internal error condition.
    #[error("Internal error: {0}")]
    Internal(String),
}

#[cfg(feature = "storage")]
impl From<rusqlite::Error> for SkybaseError {
    fn from(err: rusqlite::Error) -> Self {
        SkybaseError::Storage(err.to_string())
    }
}

impl From<skyauth::error::DPoPError> for SkybaseError {
    fn from(err: skyauth::error::DPoPError) -> Self {
        SkybaseError::Auth(err.into())
    }
}

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