aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHelmut K. C. Tessarek <[email protected]>2024-03-17 14:53:41 -0400
committerGitHub <[email protected]>2024-03-17 19:53:41 +0100
commitea04b6f151833fa726b3ad1a49761cc840dc75f1 (patch)
treecd2ff1640e4aa8f48ed0827e78392f9f06ee9872 /src
parent34272176867af1d566bd3bc561486a4e7a492ea9 (diff)
downloadvaultwarden-ea04b6f151833fa726b3ad1a49761cc840dc75f1.tar.gz
vaultwarden-ea04b6f151833fa726b3ad1a49761cc840dc75f1.zip
refactor: replace panic with a graceful exit (#4402)
* 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]>
Diffstat (limited to 'src')
-rw-r--r--src/main.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index 285dc33a..e3b29383 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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);