From 09b1665370efe84920c71310c1189d75eac1860e Mon Sep 17 00:00:00 2001 From: Eduardo Broto Date: Mon, 13 Jan 2020 23:29:11 +0100 Subject: 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. --- src/os/shared.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') 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 { -- cgit v1.2.3