use std::io;
use thiserror::Error;

/// All errors produced by bzippy2.
#[derive(Error, Debug)]
pub enum Bzippy2Error {
    /// Wraps an underlying IO error.
    #[error("IO error: {0}")]
    Io(#[from] io::Error),

    /// Error from the bzip2 backend (Phase 1).
    #[error("BZip2 backend error: {0}")]
    Backend(String),

    /// The input was truncated or otherwise invalid.
    #[error("truncated or invalid BZip2 stream: {0}")]
    Truncated(String),
}

/// Convenience alias used throughout bzippy2.
pub type Bzippy2Result<T> = Result<T, Bzippy2Error>;
