From bd15eba414df2b21bce00384ea79634a3c27670b Mon Sep 17 00:00:00 2001 From: Dominik Nakamura Date: Tue, 24 Oct 2023 17:25:52 +0900 Subject: [PATCH] feat: improve error output on compile error --- crates/stef-build/src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/stef-build/src/lib.rs b/crates/stef-build/src/lib.rs index 6e4fb93..17196b5 100644 --- a/crates/stef-build/src/lib.rs +++ b/crates/stef-build/src/lib.rs @@ -5,6 +5,7 @@ use std::{ convert::AsRef, + fmt::Debug, path::{Path, PathBuf}, }; @@ -20,7 +21,7 @@ mod encode; pub type Result = std::result::Result; -#[derive(Debug, Error)] +#[derive(Error)] pub enum Error { #[error("failed to parse the glob pattern {glob:?}")] Pattern { @@ -45,6 +46,12 @@ pub enum Error { Compile { report: Report, file: PathBuf }, } +impl Debug for Error { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{self}") + } +} + pub fn compile(schemas: &[impl AsRef], _includes: &[impl AsRef]) -> Result<()> { miette::set_hook(Box::new(|_| { Box::new(