mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 17:01:09 +03:00
Server panics when no config file is found
Can't do anything useful without config at this point, so we might as well panic rather than confuse people. Minor cleanup of config.
This commit is contained in:
parent
7281dc9473
commit
90746537a3
2 changed files with 6 additions and 12 deletions
|
@ -89,10 +89,8 @@ impl GlobalConfig {
|
||||||
Err(ConfigError::FileNotFoundError(String::from("")))
|
Err(ConfigError::FileNotFoundError(String::from("")))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Takes the path to a config file, or if NONE, tries
|
/// Takes the path to a config file, or if NONE, tries to determine a config
|
||||||
/// to determine a config file based on rules in
|
/// file based on rules in derive_config_location
|
||||||
/// derive_config_location
|
|
||||||
|
|
||||||
pub fn new(file_path: Option<&str>) -> Result<GlobalConfig, ConfigError> {
|
pub fn new(file_path: Option<&str>) -> Result<GlobalConfig, ConfigError> {
|
||||||
let mut return_value = GlobalConfig::default();
|
let mut return_value = GlobalConfig::default();
|
||||||
if let Some(fp) = file_path {
|
if let Some(fp) = file_path {
|
||||||
|
@ -119,14 +117,13 @@ impl GlobalConfig {
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to parse the config file if it exists
|
// Try to parse the config file if it exists explode if it does exist but
|
||||||
// explode if it does exist but something's wrong
|
// something's wrong with it
|
||||||
// with it
|
|
||||||
return_value.read_config()
|
return_value.read_config()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read config
|
/// Read config
|
||||||
pub fn read_config(mut self) -> Result<GlobalConfig, ConfigError> {
|
fn read_config(mut self) -> Result<GlobalConfig, ConfigError> {
|
||||||
let mut file = File::open(self.config_file_path.as_mut().unwrap())?;
|
let mut file = File::open(self.config_file_path.as_mut().unwrap())?;
|
||||||
let mut contents = String::new();
|
let mut contents = String::new();
|
||||||
file.read_to_string(&mut contents)?;
|
file.read_to_string(&mut contents)?;
|
||||||
|
|
|
@ -378,10 +378,7 @@ fn server_command(server_args: Option<&ArgMatches>, mut global_config: GlobalCon
|
||||||
.chain_type,
|
.chain_type,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
info!(
|
panic!("No configuration found.");
|
||||||
LOGGER,
|
|
||||||
"Starting the Grin server (no configuration file) ..."
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// just get defaults from the global config
|
// just get defaults from the global config
|
||||||
|
|
Loading…
Reference in a new issue