cli: Check queries when running tree-sitter test

This commit is contained in:
Max Brunsfeld 2019-10-18 14:42:52 -07:00
parent b73b31356d
commit e14e285a10
6 changed files with 69 additions and 20 deletions

View file

@ -52,7 +52,25 @@ impl Error {
impl<'a> From<QueryError> for Error {
fn from(error: QueryError) -> Self {
Error::new(format!("{:?}", error))
match error {
QueryError::Capture(row, c) => Error::new(format!(
"Query error on line {}: Invalid capture name {}",
row, c
)),
QueryError::Field(row, f) => Error::new(format!(
"Query error on line {}: Invalid field name {}",
row, f
)),
QueryError::NodeType(row, t) => Error::new(format!(
"Query error on line {}. Invalid node type {}",
row, t
)),
QueryError::Syntax(row, l) => Error::new(format!(
"Query error on line {}. Invalid syntax:\n{}",
row, l
)),
QueryError::Predicate(p) => Error::new(format!("Query error: {}", p)),
}
}
}