fix: improve error message when the tree-sitter field is malformed

This commit is contained in:
Amaan Qureshi 2024-04-18 14:17:20 -04:00
parent ac19638f71
commit 517e61b3e6

View file

@ -468,7 +468,9 @@ fn lookup_package_json_for_path(path: &Path) -> Result<(PathBuf, PackageJSON)> {
.then(|| -> Result<PackageJSON> {
let file =
File::open(pathbuf.as_path()).with_context(|| "Failed to open package.json")?;
Ok(serde_json::from_reader(BufReader::new(file))?)
serde_json::from_reader(BufReader::new(file)).context(
"Failed to parse package.json, is the `tree-sitter` section malformed?",
)
})
.transpose()?;
if let Some(package_json) = package_json {