From de39e545146a4e9b626ae2d6725a2543da05f395 Mon Sep 17 00:00:00 2001 From: kohbis <18735471+kohbis@users.noreply.github.com> Date: Sun, 10 Sep 2023 23:26:20 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20use=20anyhow::bail!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config/mod.rs b/src/config/mod.rs index 688159e..505dbc1 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -48,7 +48,7 @@ impl Config { fn read_from_file(&mut self, path: &Path) -> Result<&Self> { let file = match File::open(path) { Ok(file) => file, - Err(err) => return Err(anyhow!(err)), + Err(err) => anyhow::bail!("{}: {}", path.display(), err), }; for line in BufReader::new(file).lines() { @@ -71,7 +71,7 @@ impl Config { fn validate(&mut self) -> Result<()> { if self.token.is_empty() { - return Err(anyhow!("{} not found.", RSLACK_TOKEN)); + anyhow::bail!("{} not found.", RSLACK_TOKEN); } Ok(())