benday-core 0.3.0

Spec-to-chart rendering core for benday: terminal charts from a Vega-Lite-style JSON spec
Documentation
use std::fmt;

#[derive(Debug)]
pub enum Error {
    /// The spec parsed as JSON but is semantically invalid or unsupported.
    Spec(String),
    /// The data cannot support the requested encoding.
    Data(String),
}

impl Error {
    pub fn kind(&self) -> &'static str {
        match self {
            Error::Spec(_) => "spec",
            Error::Data(_) => "data",
        }
    }
}

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Error::Spec(m) | Error::Data(m) => f.write_str(m),
        }
    }
}

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