fix(generate)!: hold IoError inside GenerateError::GrammarPath

This commit is contained in:
Will Lillis 2026-08-20 02:32:48 -04:00
parent cde84508ac
commit baad4174e5

View file

@ -76,7 +76,7 @@ pub type GenerateResult<T> = Result<T, GenerateError>;
#[derive(Debug, Error, Serialize, Deserialize)]
pub enum GenerateError {
#[error("Error with specified path -- {0}")]
GrammarPath(String),
GrammarPath(IoError),
#[error(transparent)]
IO(IoError),
#[cfg(feature = "load")]
@ -347,7 +347,7 @@ where
let path_buf: PathBuf = path.into();
if !path_buf
.try_exists()
.map_err(|e| GenerateError::GrammarPath(e.to_string()))?
.map_err(|e| GenerateError::GrammarPath(IoError::new(e, Some(&path_buf))))?
{
// A nonexistent path with an extension (i.e. tree-sitter-foo/grammar.json)
// is a missing input file, not a directory to create.