Remove ConfigReadError because ::toml_query::error::Error is now linked in

This commit is contained in:
Matthias Beyer 2017-09-09 22:15:18 +02:00
parent a015b07f6a
commit 307165d1b2
2 changed files with 57 additions and 74 deletions

View file

@ -48,11 +48,6 @@ error_chain! {
display("IO Error: Could not open logfile") display("IO Error: Could not open logfile")
} }
ConfigReadError {
description("Error while reading the configuration")
display("Error while reading the configuration")
}
ConfigTypeError { ConfigTypeError {
description("Error while reading the configuration: Type Error") description("Error while reading the configuration: Type Error")
display("Error while reading the configuration: Type Error") display("Error while reading the configuration: Type Error")

View file

@ -195,14 +195,11 @@ fn aggregate_global_loglevel(matches: &ArgMatches, config: Option<&Configuration
-> Result<LogLevel> -> Result<LogLevel>
{ {
match config { match config {
Some(cfg) => match cfg Some(cfg) => match cfg.read("imag.logging.level") {
.read("imag.logging.level")
.chain_err(|| EK::ConfigReadError)
{
Ok(Some(&Value::String(ref s))) => match_log_level_str(s), Ok(Some(&Value::String(ref s))) => match_log_level_str(s),
Ok(Some(_)) => Err(RE::from_kind(EK::ConfigTypeError)), Ok(Some(_)) => Err(RE::from_kind(EK::ConfigTypeError)),
Ok(None) => Err(RE::from_kind(EK::GlobalLogLevelConfigMissing)), Ok(None) => Err(RE::from_kind(EK::GlobalLogLevelConfigMissing)),
Err(e) => Err(e) Err(e) => Err(e).map_err(From::from),
}, },
None => { None => {
if matches.is_present(Runtime::arg_debugging_name()) { if matches.is_present(Runtime::arg_debugging_name()) {
@ -253,14 +250,11 @@ fn aggregate_global_destinations(matches: &ArgMatches, config: Option<&Configura
{ {
match config { match config {
Some(cfg) => match cfg Some(cfg) => match cfg.read("imag.logging.destinations") {
.read("imag.logging.destinations")
.chain_err(|| EK::ConfigReadError)
{
Ok(Some(&Value::Array(ref a))) => translate_destinations(a), Ok(Some(&Value::Array(ref a))) => translate_destinations(a),
Ok(Some(_)) => Err(RE::from_kind(EK::ConfigTypeError)), Ok(Some(_)) => Err(RE::from_kind(EK::ConfigTypeError)),
Ok(None) => Err(RE::from_kind(EK::GlobalDestinationConfigMissing)), Ok(None) => Err(RE::from_kind(EK::GlobalDestinationConfigMissing)),
Err(e) => Err(e) Err(e) => Err(e).map_err(From::from),
}, },
None => { None => {
if let Some(values) = matches.value_of(Runtime::arg_logdest_name()) { if let Some(values) = matches.value_of(Runtime::arg_logdest_name()) {
@ -291,14 +285,11 @@ fn aggregate_global_format(
-> Result<String> -> Result<String>
{ {
match config { match config {
Some(cfg) => match cfg Some(cfg) => match cfg.read(read_str) {
.read(read_str)
.chain_err(|| EK::ConfigReadError)
{
Ok(Some(&Value::String(ref s))) => Ok(s.clone()), Ok(Some(&Value::String(ref s))) => Ok(s.clone()),
Ok(Some(_)) => Err(RE::from_kind(EK::ConfigTypeError)), Ok(Some(_)) => Err(RE::from_kind(EK::ConfigTypeError)),
Ok(None) => Err(RE::from_kind(error_kind_if_missing)), Ok(None) => Err(RE::from_kind(error_kind_if_missing)),
Err(e) => Err(e) Err(e) => Err(e).map_err(From::from),
}, },
None => match matches.value_of(cli_match_name).map(String::from) { None => match matches.value_of(cli_match_name).map(String::from) {
Some(s) => Ok(s), Some(s) => Ok(s),
@ -361,10 +352,7 @@ fn aggregate_module_settings(_matches: &ArgMatches, config: Option<&Configuratio
-> Result<BTreeMap<ModuleName, ModuleSettings>> -> Result<BTreeMap<ModuleName, ModuleSettings>>
{ {
match config { match config {
Some(cfg) => match cfg Some(cfg) => match cfg.read("imag.logging.modules") {
.read("imag.logging.modules")
.chain_err(|| EK::ConfigReadError)
{
Ok(Some(&Value::Table(ref t))) => { Ok(Some(&Value::Table(ref t))) => {
// translate the module settings from the table `t` // translate the module settings from the table `t`
let mut settings = BTreeMap::new(); let mut settings = BTreeMap::new();
@ -408,7 +396,7 @@ fn aggregate_module_settings(_matches: &ArgMatches, config: Option<&Configuratio
// No modules configured. This is okay! // No modules configured. This is okay!
Ok(BTreeMap::new()) Ok(BTreeMap::new())
}, },
Err(e) => Err(e), Err(e) => Err(e).map_err(From::from),
}, },
None => { None => {
write!(stderr(), "No Configuration.").ok(); write!(stderr(), "No Configuration.").ok();