tree-sitter/src/error.rs

26 lines
547 B
Rust
Raw Normal View History

2018-12-05 12:50:12 -08:00
#[derive(Debug)]
pub enum Error {
GrammarError(String),
SymbolError(String),
2018-12-08 13:44:11 -08:00
RegexError(String),
ConflictError(String),
2018-12-05 12:50:12 -08:00
}
pub type Result<T> = std::result::Result<T, Error>;
2018-12-08 13:44:11 -08:00
impl Error {
pub fn grammar(message: &str) -> Self {
Error::GrammarError(message.to_string())
}
pub fn regex(message: &str) -> Self {
Error::RegexError(message.to_string())
}
}
2018-12-05 12:50:12 -08:00
impl From<serde_json::Error> for Error {
fn from(error: serde_json::Error) -> Self {
Error::GrammarError(error.to_string())
}
}