More meaningful error message when config file does not exist.
This commit is contained in:
parent
690777aa16
commit
4c0bcac50b
1 changed files with 4 additions and 2 deletions
|
@ -2,7 +2,7 @@ use std::collections::HashMap;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::{Context, Result};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use log::{debug, info, warn};
|
use log::{debug, info, warn};
|
||||||
use tokio::io::AsyncReadExt;
|
use tokio::io::AsyncReadExt;
|
||||||
|
@ -167,7 +167,9 @@ async fn main() -> Result<()> {
|
||||||
tokio::io::stdin().read_to_string(&mut config).await?;
|
tokio::io::stdin().read_to_string(&mut config).await?;
|
||||||
} else {
|
} else {
|
||||||
tokio::fs::File::open(args.config.as_ref().unwrap())
|
tokio::fs::File::open(args.config.as_ref().unwrap())
|
||||||
.await?
|
.await.with_context(
|
||||||
|
|| format!("Failed to read config file {}", args.config.as_ref().unwrap().to_string_lossy())
|
||||||
|
)?
|
||||||
.read_to_string(&mut config)
|
.read_to_string(&mut config)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue