mirror of
https://github.com/coredns/coredns.git
synced 2026-05-26 03:40: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:
@@ -3,6 +3,7 @@ package geoip
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/netip"
|
||||
"path/filepath"
|
||||
@@ -42,7 +43,7 @@ var probingIP = netip.MustParseAddr("127.0.0.1")
|
||||
func newGeoIP(dbPath string, edns0 bool) (*GeoIP, error) {
|
||||
reader, err := geoip2.Open(dbPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to open database file: %v", err)
|
||||
return nil, fmt.Errorf("failed to open database file: %w", err)
|
||||
}
|
||||
db := db{Reader: reader}
|
||||
schemas := []struct {
|
||||
@@ -57,8 +58,9 @@ func newGeoIP(dbPath string, edns0 bool) (*GeoIP, error) {
|
||||
for _, schema := range schemas {
|
||||
if err := schema.validate(); err != nil {
|
||||
// If we get an InvalidMethodError then we know this database does not provide that schema.
|
||||
if _, ok := err.(geoip2.InvalidMethodError); !ok {
|
||||
return nil, fmt.Errorf("unexpected failure looking up database %q schema %q: %v", filepath.Base(dbPath), schema.name, err)
|
||||
var invalidMethodErr geoip2.InvalidMethodError
|
||||
if !errors.As(err, &invalidMethodErr) {
|
||||
return nil, fmt.Errorf("unexpected failure looking up database %q schema %q: %w", filepath.Base(dbPath), schema.name, err)
|
||||
}
|
||||
} else {
|
||||
db.provides |= schema.provides
|
||||
|
||||
Reference in New Issue
Block a user