Skip to content

Commit

Permalink
graceful exit for empty config file
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteOtter committed Sep 7, 2023
1 parent c70c096 commit 46bc952
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/configuration/config_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use serde::Deserialize;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
use std::process;
use std::{fs, path::PathBuf};
use toml::Value;

Expand Down Expand Up @@ -86,10 +87,11 @@ pub fn set_up_configuration(
}

if uri.is_none() || token.is_none() {
panic!(
println!(
"x1b[31mFATAL:x1b[0m No configuration parameters found in CLI while using an empty config file!\n
Please enter valid configuration parameters in the configuration file or provide them via the CLI."
)
);
process::exit(1);
}

conf_data = ConfigData::read_config_file();
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ fn main() {
let config: ConfigData = match set_up_configuration(args.uri, args.token) {
Ok(conf) => conf,
Err(err) => {
// This behavior will change
panic!("{}", err)
}
};
Expand Down

0 comments on commit 46bc952

Please sign in to comment.