//! Structural error types.
//!
//! Every recoverable failure flows through [`anyhow::Result`]; this module
//! holds only the markers that callers need to pattern-match on.

use std::fmt;

/// Returned when the user cancels an interactive operation (for example,
/// hits `Esc` in the picker or `Ctrl-C` at a prompt).
///
/// `main` downcasts to this type to choose the conventional shell exit code
/// (`130`) rather than printing a bogus "error: canceled" line.
#[derive(Debug)]
pub struct Canceled;

impl fmt::Display for Canceled {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        f.write_str("canceled")
    }
}

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