mirror of
https://github.com/coredns/coredns.git
synced 2026-05-25 19:30:23 -04:00
lint(errorlint): handle wrapped errors
Enable errorlint and preserve wrapped error chains so runtime checks and tests classify failures correctly. This also makes Route53 surface insert failures instead of silently dropping them. Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
This commit is contained in:
@@ -169,7 +169,7 @@ func (f *Forward) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
|
||||
for {
|
||||
ret, err = proxy.Connect(ctx, state, opts)
|
||||
|
||||
if err == proxyPkg.ErrCachedClosed { // Remote side closed conn, can only happen with TCP.
|
||||
if errors.Is(err, proxyPkg.ErrCachedClosed) { // Remote side closed conn, can only happen with TCP.
|
||||
continue
|
||||
}
|
||||
// Retry with TCP if truncated and prefer_udp configured.
|
||||
|
||||
@@ -2,6 +2,7 @@ package forward
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -343,8 +344,8 @@ func TestAllUpstreamsDown(t *testing.T) {
|
||||
t.Errorf("Expected Response code: %d, Got: %d", dns.RcodeServerFailure, resp)
|
||||
}
|
||||
|
||||
if err != ErrNoHealthy {
|
||||
t.Errorf("Expected error message: no healthy proxies, Got: %s", err.Error())
|
||||
if !errors.Is(err, ErrNoHealthy) {
|
||||
t.Errorf("Expected error message: no healthy proxies, Got: %v", err)
|
||||
}
|
||||
|
||||
q1 := atomic.LoadUint32(&qs)
|
||||
@@ -358,7 +359,7 @@ func TestAllUpstreamsDown(t *testing.T) {
|
||||
req = new(dns.Msg)
|
||||
req.SetQuestion("example.org.", dns.TypeA)
|
||||
_, err = f.ServeDNS(context.TODO(), &test.ResponseWriter{}, req)
|
||||
if err == ErrNoHealthy {
|
||||
if errors.Is(err, ErrNoHealthy) {
|
||||
t.Error("Unexpected error message: no healthy proxies")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user