use std::path::PathBuf;
use thiserror::Error;
#[derive(Debug, Error, Clone, PartialEq, Eq)]
pub enum IndexError {
#[error("cannot read {path}: {message}")]
Io {
path: PathBuf,
message: String,
},
#[error("{path}: {message}")]
Format {
path: PathBuf,
message: String,
},
#[error("invalid identifier {0:?}")]
InvalidIdentifier(String),
#[error("cyclic superclasses: {0}")]
CyclicBase(String),
#[error("tree-sitter could not load the MATLAB grammar: {0}")]
Grammar(String),
#[error("invalid .malt.toml: {0}")]
Config(String),
}
impl IndexError {
pub(crate) fn io(path: &std::path::Path, err: &std::io::Error) -> Self {
IndexError::Io {
path: path.to_path_buf(),
message: err.to_string(),
}
}
}