From e7e12e4c27ba462a9f8e6ec15373d00c3d72bb24 Mon Sep 17 00:00:00 2001 From: Hristo Venev Date: Mon, 30 Sep 2019 14:54:09 +0300 Subject: Lowercase errors. --- src/manager/builder.rs | 16 ++++++++-------- src/manager/mod.rs | 22 +++++++++++++++++----- 2 files changed, 25 insertions(+), 13 deletions(-) (limited to 'src/manager') diff --git a/src/manager/builder.rs b/src/manager/builder.rs index 037d2a9..9580d07 100644 --- a/src/manager/builder.rs +++ b/src/manager/builder.rs @@ -38,9 +38,9 @@ impl fmt::Display for Error { f, "{} [{}]/[{}]: {}", if self.important { - "Invalid peer" + "invalid peer" } else { - "Misconfigured peer" + "misconfigured peer" }, self.src, self.peer, @@ -108,7 +108,7 @@ impl<'a> ConfigBuilder<'a> { if p.peer.public_key == self.public_key { self.err.push(Error::new( - "The local peer cannot be a road warrior", + "the local peer cannot be a road warrior", src, &p.peer, true, @@ -122,7 +122,7 @@ impl<'a> ConfigBuilder<'a> { ent } else { self.err - .push(Error::new("Unknown base peer", src, &p.peer, true)); + .push(Error::new("unknown base peer", src, &p.peer, true)); return; }; add_peer(&mut self.err, ent, src, &p.peer) @@ -140,7 +140,7 @@ fn insert_peer<'b>( ) -> &'b mut model::Peer { match c.peers.entry(p.public_key) { hash_map::Entry::Occupied(ent) => { - err.push(Error::new("Duplicate public key", src, p, true)); + err.push(Error::new("duplicate public key", src, p, true)); ent.into_mut() } hash_map::Entry::Vacant(ent) => { @@ -169,7 +169,7 @@ fn find_psk<'a>( if let Some(ref want_src) = &want.source { if *want_src != src.name { - return Err(Error::new("Peer source not allowed", src, p, true)); + return Err(Error::new("peer source not allowed", src, p, true)); } } @@ -199,9 +199,9 @@ fn add_peer(err: &mut Vec, ent: &mut model::Peer, src: &Source, p: &proto if removed { let msg = if added { - "Some IPs removed" + "some IPs removed" } else { - "All IPs removed" + "all IPs removed" }; err.push(Error::new(msg, src, p, !added)); } diff --git a/src/manager/mod.rs b/src/manager/mod.rs index 0d180a6..20ec061 100644 --- a/src/manager/mod.rs +++ b/src/manager/mod.rs @@ -33,7 +33,7 @@ pub struct Manager { impl Manager { pub fn new(ifname: OsString, c: config::Config) -> io::Result { let runtime_directory = c.runtime_directory.ok_or_else(|| { - io::Error::new(io::ErrorKind::InvalidInput, "Runtime directory required") + io::Error::new(io::ErrorKind::InvalidInput, "runtime directory required") })?; let mut state_path = runtime_directory.clone(); state_path.push("state.json"); @@ -122,7 +122,7 @@ impl Manager { } Err(io::Error::new( io::ErrorKind::Other, - format!("Failed to update required source [{}]", &s.config.url), + format!("failed to update required source [{}]", &s.config.url), )) } @@ -196,9 +196,21 @@ impl Manager { let t_cfg = now + time_to_cfg; if config != self.current { - eprintln!("<5>Applying configuration update"); - for err in &errors { - eprintln!("<{}>{}", if err.important() { '4' } else { '5' }, err); + if errors.is_empty() { + eprintln!("<5>Applying configuration update"); + } else { + eprint!( + "<{}>New update contains errors: ", + if errors.iter().any(|err| err.important()) { + '4' + } else { + '5' + } + ); + for err in &errors { + eprint!("{}; ", err); + } + eprintln!("applying anyway"); } self.dev.apply_diff(&self.current, &config)?; self.current_update(&config); -- cgit