Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

2.1 KB
Raw Blame
use std::fmt;

/// Error indicating an upload operation was cancelled (e.g., due to rebalance or shutdown).
/// Use anyhow's downcast_ref::<UploadCancelledError>() to detect this error type.
#[derive(Debug)]
pub struct UploadCancelledError {
    pub reason: String,
}

impl fmt::Display for UploadCancelledError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "Upload cancelled: {}", self.reason)
    }
}

impl std::error::Error for UploadCancelledError {}

/// Error indicating a download operation was cancelled (e.g., due to rebalance or shutdown).
/// Use anyhow's downcast_ref::<DownloadCancelledError>() to detect this error type.
#[derive(Debug)]
pub struct DownloadCancelledError {
    pub reason: String,
}

impl fmt::Display for DownloadCancelledError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "Download cancelled: {}", self.reason)
    }
}

impl std::error::Error for DownloadCancelledError {}

/// Error indicating checkpoint planning was cancelled before upload started.
/// Use anyhow's downcast_ref::<PlanningCancelledError>() to detect this error type.
#[derive(Debug)]
pub struct PlanningCancelledError {
    pub reason: String,
}

impl fmt::Display for PlanningCancelledError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "Checkpoint planning cancelled: {}", self.reason)
    }
}

impl std::error::Error for PlanningCancelledError {}

/// Error indicating a checkpoint import operation timed out.
/// This prevents exceeding Kafka's max poll interval during long imports.
/// Use anyhow's downcast_ref::<ImportTimeoutError>() to detect this error type.
#[derive(Debug)]
pub struct ImportTimeoutError {
    pub topic: String,
    pub partition: i32,
    pub timeout_secs: u64,
}

impl fmt::Display for ImportTimeoutError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(
            f,
            "Checkpoint import timed out after {}s for {}:{}",
            self.timeout_secs, self.topic, self.partition
        )
    }
}

impl std::error::Error for ImportTimeoutError {}