mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
cli_helpers: better error messages for config file opening/reading
This commit is contained in:
parent
80c924d461
commit
a5b1fa619a
1 changed files with 12 additions and 4 deletions
|
|
@ -64,11 +64,19 @@ fn run_inner<T>(
|
|||
fn config_from_toml_file<T>(path: String) -> anyhow::Result<T>
|
||||
where T: DeserializeOwned
|
||||
{
|
||||
let mut file = File::open(path)?;
|
||||
let mut data = String::new();
|
||||
file.read_to_string(&mut data)?;
|
||||
let mut file = File::open(path.clone()).with_context(||
|
||||
format!("Couldn't open config file {}", path.clone())
|
||||
)?;
|
||||
|
||||
toml::from_str(&data).context("Couldn't parse config file")
|
||||
let mut data = String::new();
|
||||
|
||||
file.read_to_string(&mut data).with_context(||
|
||||
format!("Couldn't read config file {}", path.clone())
|
||||
)?;
|
||||
|
||||
toml::from_str(&data).with_context(||
|
||||
format!("Couldn't parse config file {}", path.clone())
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue