diff --git a/cli/src/error.rs b/cli/src/error.rs index 824bd92f..d583d1b9 100644 --- a/cli/src/error.rs +++ b/cli/src/error.rs @@ -83,7 +83,7 @@ impl<'a> From for Error { impl<'a> From for Error { fn from(error: tree_sitter_tags::Error) -> Self { - Error::new(format!("{:?}", error)) + Error::new(format!("{}", error)) } } diff --git a/tags/src/lib.rs b/tags/src/lib.rs index 3d5ce770..07fed3af 100644 --- a/tags/src/lib.rs +++ b/tags/src/lib.rs @@ -62,6 +62,15 @@ pub enum Error { InvalidCapture(String), } +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + Error::InvalidCapture(name) => write!(f, "Invalid capture @{}. Expected one of: @definition.*, @reference.*, @doc, @name, @local.(scope|definition|reference).", name), + _ => write!(f, "{:?}", self) + } + } +} + #[derive(Debug, Default)] struct PatternInfo { docs_adjacent_capture: Option,