refactor: move i/e/n/errorx to i/errorsx (#416)

Still working towards https://github.com/ooni/probe/issues/1505
This commit is contained in:
Simone Basso
2021-07-01 16:34:36 +02:00
committed by GitHub
parent 6895946a34
commit 72acd175a0
58 changed files with 287 additions and 287 deletions
+2 -2
View File
@@ -4,7 +4,7 @@ import (
"context"
"net"
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
"github.com/ooni/probe-cli/v3/internal/errorsx"
"github.com/ooni/probe-cli/v3/internal/runtimex"
)
@@ -65,7 +65,7 @@ func (r BogonResolver) LookupHost(ctx context.Context, hostname string) ([]strin
addrs, err := r.Resolver.LookupHost(ctx, hostname)
for _, addr := range addrs {
if IsBogon(addr) {
return nil, errorx.ErrDNSBogon
return nil, errorsx.ErrDNSBogon
}
}
return addrs, err
+2 -2
View File
@@ -5,8 +5,8 @@ import (
"errors"
"testing"
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
"github.com/ooni/probe-cli/v3/internal/engine/netx/resolver"
"github.com/ooni/probe-cli/v3/internal/errorsx"
)
func TestResolverIsBogon(t *testing.T) {
@@ -29,7 +29,7 @@ func TestBogonAwareResolverWithBogon(t *testing.T) {
Resolver: resolver.NewFakeResolverWithResult([]string{"127.0.0.1"}),
}
addrs, err := r.LookupHost(context.Background(), "dns.google.com")
if !errors.Is(err, errorx.ErrDNSBogon) {
if !errors.Is(err, errorsx.ErrDNSBogon) {
t.Fatal("not the error we expected")
}
if len(addrs) > 0 {
@@ -3,7 +3,7 @@ package resolver
import (
"context"
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
"github.com/ooni/probe-cli/v3/internal/errorsx"
)
// ErrorWrapperResolver is a Resolver that knows about wrapping errors.
@@ -14,10 +14,10 @@ type ErrorWrapperResolver struct {
// LookupHost implements Resolver.LookupHost
func (r ErrorWrapperResolver) LookupHost(ctx context.Context, hostname string) ([]string, error) {
addrs, err := r.Resolver.LookupHost(ctx, hostname)
err = errorx.SafeErrWrapperBuilder{
Classifier: errorx.ClassifyResolveFailure,
err = errorsx.SafeErrWrapperBuilder{
Classifier: errorsx.ClassifyResolveFailure,
Error: err,
Operation: errorx.ResolveOperation,
Operation: errorsx.ResolveOperation,
}.MaybeBuild()
return addrs, err
}
@@ -5,8 +5,8 @@ import (
"errors"
"testing"
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
"github.com/ooni/probe-cli/v3/internal/engine/netx/resolver"
"github.com/ooni/probe-cli/v3/internal/errorsx"
)
func TestErrorWrapperSuccess(t *testing.T) {
@@ -32,14 +32,14 @@ func TestErrorWrapperFailure(t *testing.T) {
if addrs != nil {
t.Fatal("expected nil addr here")
}
var errWrapper *errorx.ErrWrapper
var errWrapper *errorsx.ErrWrapper
if !errors.As(err, &errWrapper) {
t.Fatal("cannot properly cast the returned error")
}
if errWrapper.Failure != errorx.FailureDNSNXDOMAINError {
if errWrapper.Failure != errorsx.FailureDNSNXDOMAINError {
t.Fatal("unexpected failure")
}
if errWrapper.Operation != errorx.ResolveOperation {
if errWrapper.Operation != errorsx.ResolveOperation {
t.Fatal("unexpected Operation")
}
}