coralogix-cli 0.1.30

Coralogix CLI - the observability backbone for AI agents and engineering teams.
Documentation
use thiserror::Error;

#[derive(Debug, Error)]
pub enum CxError {
    #[error("Authentication failed: {0}")]
    Auth(String),

    #[error("Permission denied: {0}")]
    Permission(String),

    #[error("API request failed ({status}): {message}")]
    Api { status: u16, message: String },

    #[error("HTTP request timed out")]
    Timeout,

    #[error("HTTP error: {0}")]
    Http(reqwest::Error),

    #[error("JSON error: {0}")]
    Json(#[from] serde_json::Error),

    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),

    #[error("Query stream error: {0}")]
    QueryStream(String),
}

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

impl From<reqwest::Error> for CxError {
    fn from(error: reqwest::Error) -> Self {
        if error.is_timeout() {
            Self::Timeout
        } else {
            Self::Http(error)
        }
    }
}