use super::InterpretErrorKind;
use crate::parser::Expr;
use crate::{InterpretError, Location};

/// Error handling extension trait.
///
/// Both constructors return a bare [`InterpretError`]; attach an optional clarifying
/// message or help line with the [`InterpretError::with_message`] /
/// [`InterpretError::with_help`] builder methods at the call site.
pub trait InterpretErrorExt {
    /// Generate an error based on the current state of the interpreter.
    fn error(&self, expr: &Expr, kind: InterpretErrorKind) -> InterpretError;

    /// Generate an error at a specific location.
    fn error_at(
        &self,
        loc: &Location,
        length: Option<usize>,
        kind: InterpretErrorKind,
    ) -> InterpretError;
}
