2021-02-02 12:05:47 +01:00
|
|
|
package resolver
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2021-07-01 16:34:36 +02:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
2021-02-02 12:05:47 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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)
|
2021-07-01 16:34:36 +02:00
|
|
|
err = errorsx.SafeErrWrapperBuilder{
|
|
|
|
Classifier: errorsx.ClassifyResolveFailure,
|
2021-06-23 13:36:45 +02:00
|
|
|
Error: err,
|
2021-07-01 16:34:36 +02:00
|
|
|
Operation: errorsx.ResolveOperation,
|
2021-02-02 12:05:47 +01:00
|
|
|
}.MaybeBuild()
|
|
|
|
return addrs, err
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ Resolver = ErrorWrapperResolver{}
|