ooni-probe-cli/internal/engine/netx/resolver/errorwrapper.go
2021-07-01 16:34:36 +02:00

26 lines
628 B
Go

package resolver
import (
"context"
"github.com/ooni/probe-cli/v3/internal/errorsx"
)
// ErrorWrapperResolver is a Resolver that knows about wrapping errors.
type ErrorWrapperResolver struct {
Resolver
}
// LookupHost implements Resolver.LookupHost
func (r ErrorWrapperResolver) LookupHost(ctx context.Context, hostname string) ([]string, error) {
addrs, err := r.Resolver.LookupHost(ctx, hostname)
err = errorsx.SafeErrWrapperBuilder{
Classifier: errorsx.ClassifyResolveFailure,
Error: err,
Operation: errorsx.ResolveOperation,
}.MaybeBuild()
return addrs, err
}
var _ Resolver = ErrorWrapperResolver{}