Skip to content

Commit

Permalink
refactor: replace panic with a graceful exit (dani-garcia#4402)
Browse files Browse the repository at this point in the history
* refactor: replace panic with a graceful exit

* fix: clippy errors

* fix: typo

* Update src/main.rs

Co-authored-by: Stefan Melmuk <[email protected]>

---------

Co-authored-by: Stefan Melmuk <[email protected]>
  • Loading branch information
tessus and stefan0xC authored Mar 17, 2024
1 parent 3427217 commit ea04b6f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ async fn main() -> Result<(), Error> {
launch_info();

use log::LevelFilter as LF;
let level = LF::from_str(&CONFIG.log_level()).expect("Valid log level");
let level = LF::from_str(&CONFIG.log_level()).unwrap_or_else(|_| {
let valid_log_levels = LF::iter().map(|lvl| lvl.as_str().to_lowercase()).collect::<Vec<String>>().join(", ");
println!("Log level must be one of the following: {valid_log_levels}");
exit(1);
});
init_logging(level).ok();

let extra_debug = matches!(level, LF::Trace | LF::Debug);
Expand Down

0 comments on commit ea04b6f

Please sign in to comment.