fix(cli): improve error message when language in list can't be found (#4643)
Problem: When multiple input paths are provided to the `parse` command (a la `tree-sitter parse --paths [...]`), if a language can't be found for one of the paths, it can be a little unclear *which* path caused the failure. The loader *can* fail with `Failed to load language for file name <foo.bar>`, but this isn't guaranteed.
Solution: Attach some additional context in the case where multiple paths can be provided, displaying the problematic path on failure.
(cherry picked from commit 9ced6172de)
This commit is contained in:
parent
05bfeb5b69
commit
0c83a5d03e
1 changed files with 5 additions and 2 deletions
|
|
@ -965,8 +965,11 @@ impl Parse {
|
|||
|
||||
for path in &paths {
|
||||
let path = Path::new(&path);
|
||||
let language =
|
||||
loader.select_language(path, current_dir, self.scope.as_deref())?;
|
||||
let language = loader
|
||||
.select_language(path, current_dir, self.scope.as_deref())
|
||||
.with_context(|| {
|
||||
anyhow!("Failed to load langauge for path \"{}\"", path.display())
|
||||
})?;
|
||||
|
||||
parse::parse_file_at_path(
|
||||
&mut parser,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue