From 1c88e84f758e6daa0237a86930a96044c9db252c Mon Sep 17 00:00:00 2001 From: FlareFlo Date: Fri, 23 Feb 2024 14:17:23 +0100 Subject: [PATCH] Bail instead of panic --- src/subcommands/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/subcommands/mod.rs b/src/subcommands/mod.rs index c36d46c..0e75526 100644 --- a/src/subcommands/mod.rs +++ b/src/subcommands/mod.rs @@ -1,7 +1,7 @@ use std::{str::FromStr, sync::OnceLock}; use clap::ArgMatches; -use color_eyre::eyre::{bail, Result}; +use color_eyre::eyre::{bail, Context, Result}; use tracing::metadata::LevelFilter; use crate::{ @@ -30,7 +30,7 @@ pub fn branch_subcommands(args: ArgMatches) -> Result<()> { .expect("Failed to set CRASHLOG global flag"); let log_level = if let Some(lvl) = args.get_one::("log_level") { - LevelFilter::from_str(lvl).expect(&format!("Incorrect log-level provided, expected one of [Trace, Debug, Info, Warn, Error], found {lvl}")) + LevelFilter::from_str(lvl).context(format!("Incorrect log-level provided, expected one of [Trace, Debug, Info, Warn, Error], found {lvl}"))? } else { LevelFilter::WARN }; @@ -51,7 +51,7 @@ pub fn branch_subcommands(args: ArgMatches) -> Result<()> { unpack_dxp_and_grp(args)?; }, Some(("get_instruction_manual", _)) => { - open::that("https://github.com/Warthunder-Open-Source-Foundation/wt_ext_cli/blob/master/usage_manual.md").expect("Attempted to show manual in browser, but something unexpected failed"); + open::that("https://github.com/Warthunder-Open-Source-Foundation/wt_ext_cli/blob/master/usage_manual.md").context("Attempted to show manual in browser, but something unexpected failed")?; }, Some(("hash", _)) => { println!("https://github.com/Warthunder-Open-Source-Foundation/wt_ext_cli/commit/{COMMIT_HASH}");