Chore: picker support get first error

This commit is contained in:
Dreamacro
2020-04-16 18:31:40 +08:00
parent 1825535abd
commit 5c03613858
3 changed files with 20 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import (
"context"
"crypto/tls"
"errors"
"fmt"
"math/rand"
"net"
"strings"
@ -182,7 +183,11 @@ func (r *Resolver) batchExchange(clients []dnsClient, m *D.Msg) (msg *D.Msg, err
elm := fast.Wait()
if elm == nil {
return nil, errors.New("All DNS requests failed")
err := errors.New("All DNS requests failed")
if fErr := fast.Error(); fErr != nil {
err = fmt.Errorf("%w, first error: %s", err, fErr.Error())
}
return nil, err
}
msg = elm.(*D.Msg)