use thiserror::Error;

#[derive(Error, Debug)]
pub enum EgregoreError {
    #[error("not authenticated — call register() or resume() first")]
    NotAuthenticated,

    #[error("backend returned {status}: {body}")]
    Backend { status: u16, body: String },

    #[error(transparent)]
    Network(#[from] reqwest::Error),

    #[error(transparent)]
    Json(#[from] serde_json::Error),

    #[error("other error: {0}")]
    Other(String),
}

pub type Result<T> = std::result::Result<T, EgregoreError>;
