diff --git a/libimagrt/src/configuration.rs b/libimagrt/src/configuration.rs index 7eb8e30f..f5f06662 100644 --- a/libimagrt/src/configuration.rs +++ b/libimagrt/src/configuration.rs @@ -16,7 +16,6 @@ pub mod error { */ #[derive(Clone, Debug, PartialEq)] pub enum ConfigErrorKind { - ConfigNotFound, ConfigParsingFailed, NoConfigFileFound, } @@ -54,7 +53,6 @@ pub mod error { */ pub fn as_str(e: &ConfigError) -> &'static str { match e.kind() { - ConfigErrorKind::ConfigNotFound => "Config not found", ConfigErrorKind::ConfigParsingFailed => "Config parsing failed", ConfigErrorKind::NoConfigFileFound => "No config file found", } diff --git a/libimagrt/src/runtime.rs b/libimagrt/src/runtime.rs index c5b7412f..a1cbc63d 100644 --- a/libimagrt/src/runtime.rs +++ b/libimagrt/src/runtime.rs @@ -15,7 +15,7 @@ use libimagstore::store::Store; pub struct Runtime<'a> { rtp: PathBuf, - configuration: Configuration, + configuration: Option, cli_matches: ArgMatches<'a>, store: Store, } @@ -34,6 +34,8 @@ impl<'a> Runtime<'a> { use std::env; use std::error::Error; + use configuration::error::ConfigErrorKind; + let matches = cli_spec.get_matches(); let rtp : PathBuf = matches.value_of("runtimepath") .map(PathBuf::from) @@ -54,11 +56,17 @@ impl<'a> Runtime<'a> { }); let cfg = Configuration::new(&rtp); - if cfg.is_err() { - let cause : Option> = Some(Box::new(cfg.err().unwrap())); - return Err(RuntimeError::new(RuntimeErrorKind::Instantiate, cause)); - } - let cfg = cfg.unwrap(); + let cfg = if cfg.is_err() { + let e = cfg.err().unwrap(); + if e.kind() != ConfigErrorKind::NoConfigFileFound { + let cause : Option> = Some(Box::new(e)); + return Err(RuntimeError::new(RuntimeErrorKind::Instantiate, cause)); + } else { + None + } + } else { + Some(cfg.unwrap()) + }; Store::new(storepath).map(|store| { Runtime {