Merge pull request #1234 from ahlinc/fix/imrove-config-loading-err-msgs
fix(cli): Improve error messages on config.json loading, closes #1227
This commit is contained in:
commit
64e6c11566
1 changed files with 5 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
|||
//! Manages tree-sitter's configuration file.
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use std::path::PathBuf;
|
||||
|
|
@ -65,8 +65,10 @@ impl Config {
|
|||
Some(location) => location,
|
||||
None => return Config::initial(),
|
||||
};
|
||||
let content = fs::read_to_string(&location)?;
|
||||
let config = serde_json::from_str(&content)?;
|
||||
let content = fs::read_to_string(&location)
|
||||
.with_context(|| format!("Failed to read {}", &location.to_string_lossy()))?;
|
||||
let config = serde_json::from_str(&content)
|
||||
.with_context(|| format!("Bad JSON config {}", &location.to_string_lossy()))?;
|
||||
Ok(Config { location, config })
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue