diff --git a/lrlex/src/lib/ctbuilder.rs b/lrlex/src/lib/ctbuilder.rs index e5c4b5d93..a0d317a75 100644 --- a/lrlex/src/lib/ctbuilder.rs +++ b/lrlex/src/lib/ctbuilder.rs @@ -325,7 +325,8 @@ where lk.insert(outp.clone()); } - let lex_src = read_to_string(lexerp)?; + let lex_src = read_to_string(lexerp) + .map_err(|e| format!("When reading '{}': {e}", lexerp.display()))?; let line_cache = NewlineCache::from_str(&lex_src).unwrap(); let mut lexerdef: Box> = match self.lexerkind { LexerKind::LRNonStreamingLexer => Box::new( diff --git a/lrpar/src/lib/ctbuilder.rs b/lrpar/src/lib/ctbuilder.rs index b2435d9e2..0819f75c2 100644 --- a/lrpar/src/lib/ctbuilder.rs +++ b/lrpar/src/lib/ctbuilder.rs @@ -414,7 +414,8 @@ where lk.insert(outp.clone()); } - let inc = read_to_string(grmp).unwrap(); + let inc = + read_to_string(grmp).map_err(|e| format!("When reading '{}': {e}", grmp.display()))?; let ast_validation = ASTWithValidityInfo::new(yk, &inc); let warnings = ast_validation.ast().warnings(); let spanned_fmt = |x: &dyn Spanned, inc: &str, line_cache: &NewlineCache| {