[go-nuts] net/http and errors.

2016-11-25 Thread mb . dhananjay
This is a question about the net/http API, Googling was not very helpful. _, err := http.Get("https://random_non_existing_domain.com";) Following code will obviously fail, but how can I check if it failed because of DNS error not because a billion other things that might have gone wrong?

[go-nuts] Re: net/http and errors.

2016-11-28 Thread mb . dhananjay
But AFIU, err.Temporary() could be true for other kind of errors that might happen, isn't that a problem if I only want to handle DNS errors? On Friday, November 25, 2016 at 6:35:59 PM UTC+1, Victor Vrantchan wrote: > > In Go, you can check if a type satisfies a particular behavior by > declari

[go-nuts] Re: net/http and errors.

2016-11-28 Thread mb . dhananjay
I'm downloading a large number of urls and the result is expected to have failure reasons, DNS lookup failed being one. calling lookup manually would solve my issue, I suppose. Just wanted to make sure that I'm not missing any obvious solutions. 1. lookup DNS and if it succeeds, 2. try http.Ge

[go-nuts] Re: net/http and errors.

2016-12-01 Thread mb . dhananjay
> if err, ok := err.(*url.Error); ok { > if err, ok := err.Err.(*net.OpError); ok { > if err, ok := err.Err.(*net.DNSError); ok { > fmt.Println("DNS ERROR:", err) > } > } > } > This works as expected. :-) On Monday, November 28, 2016 at 9:32:55 PM UTC+1, Dave Cheney wrote: > > Indeed. Does your