> 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
Indeed. Does your program differentiate between a URL not resolving, the
webserver at the other end being down or refusing to connect, or it returnining
a non temporary fatal error, 4xx?
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsub
If you want to assert your way down to the original error, the order of the
structures returned from http.Get is:
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)
}
}
}
Again though, the act
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
What specifically do you want to handle about DNS errors ?
If you have a set of possible dns names and you don't know if some of them
are valid, you could use net.LookupHost to check which ones are valid
before calling http.Get.
On Monday, 28 November 2016 22:44:37 UTC+11, mb.dha...@gmail.com w
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
In Go, you can check if a type satisfies a particular behavior by declaring
an interface, and then checking if the type satisfies that interface.
In your case, you can check if the error is `Temporrary()` or not.
See this snippet as an example: https://play.golang.org/p/Ffyg61iDpB
I
recommend