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:
Ville Vesilehto
2026-04-25 11:51:45 +03:00
parent a669d74088
commit 3080ec0448
53 changed files with 122 additions and 89 deletions

View File

@@ -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