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.
This commit is contained in:
parent
07b4c8d05d
commit
9ced6172de
1 changed files with 5 additions and 2 deletions
|
|
@ -1023,8 +1023,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