refactor(errorsx): start hiding private details and moving around stuff (#424)
* refactor(errorsx): start hiding private details and moving around stuff Part of https://github.com/ooni/probe/issues/1505 * fix: remove now-addressed todo comments
This commit is contained in:
parent
ceb2aa8a8d
commit
17bfb052c5
8 changed files with 235 additions and 236 deletions
|
|
@ -1,6 +1,9 @@
|
|||
package errorsx
|
||||
|
||||
import "context"
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// Resolver is a DNS resolver. The *net.Resolver used by Go implements
|
||||
// this interface, but other implementations are possible.
|
||||
|
|
@ -20,13 +23,21 @@ var _ Resolver = &ErrorWrapperResolver{}
|
|||
func (r *ErrorWrapperResolver) LookupHost(ctx context.Context, hostname string) ([]string, error) {
|
||||
addrs, err := r.Resolver.LookupHost(ctx, hostname)
|
||||
err = SafeErrWrapperBuilder{
|
||||
Classifier: ClassifyResolveFailure,
|
||||
Classifier: classifyResolveFailure,
|
||||
Error: err,
|
||||
Operation: ResolveOperation,
|
||||
}.MaybeBuild()
|
||||
return addrs, err
|
||||
}
|
||||
|
||||
// classifyResolveFailure is a classifier to translate DNS resolving errors to OONI error strings.
|
||||
func classifyResolveFailure(err error) string {
|
||||
if errors.Is(err, ErrDNSBogon) {
|
||||
return FailureDNSBogonError // not in MK
|
||||
}
|
||||
return toFailureString(err)
|
||||
}
|
||||
|
||||
type resolverNetworker interface {
|
||||
Network() string
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue