From 4c0bcac50b006f6067f9c4762d784f1daae6d881 Mon Sep 17 00:00:00 2001 From: redxef Date: Sun, 15 Oct 2023 15:44:49 +0200 Subject: [PATCH] More meaningful error message when config file does not exist. --- src/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index c88504d..5a6af77 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use std::path::PathBuf; use std::str::FromStr; -use anyhow::Result; +use anyhow::{Context, Result}; use clap::Parser; use log::{debug, info, warn}; use tokio::io::AsyncReadExt; @@ -167,7 +167,9 @@ async fn main() -> Result<()> { tokio::io::stdin().read_to_string(&mut config).await?; } else { 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) .await?; }