summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEduardo Broto <ebroto@tutanota.com>2020-01-13 23:29:11 +0100
committerEduardo Broto <ebroto@tutanota.com>2020-01-13 23:29:11 +0100
commit09b1665370efe84920c71310c1189d75eac1860e (patch)
tree50c991f612ef41bef2e1b7697a2985ffe531b2c8
parente6c58c6021ffad2d0af6434e0d4521342a0d4b42 (diff)
fix(dns): display a more informative message in case we can't resolve
Tested in Linux. When offline, /etc/resolve.conf is a broken symlink, so opening it yields an IO error. It should work similarly in other OSs as the resolver is OS-agnostic. Before, the message was simply: Error: io error. After this change, a more informative message is shown.
-rw-r--r--src/os/shared.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/os/shared.rs b/src/os/shared.rs
index 852d4f7..afa7330 100644
--- a/src/os/shared.rs
+++ b/src/os/shared.rs
@@ -123,7 +123,10 @@ pub fn get_input(
let (on_winch, cleanup) = sigwinch();
let dns_client = if resolve {
let mut runtime = Runtime::new()?;
- let resolver = runtime.block_on(dns::Resolver::new(runtime.handle().clone()))?;
+ let resolver = match runtime.block_on(dns::Resolver::new(runtime.handle().clone())) {
+ Ok(resolver) => resolver,
+ Err(_) => failure::bail!("Could not initialize the DNS resolver. Are you offline?"),
+ };
let dns_client = dns::Client::new(resolver, runtime)?;
Some(dns_client)
} else {