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
@@ -5,7 +5,7 @@ import (
"crypto/tls"
"github.com/lucas-clemente/quic-go"
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
"github.com/ooni/probe-cli/v3/internal/errorsx"
)
// ErrorWrapperDialer is a dialer that performs quic err wrapping
@@ -18,10 +18,10 @@ func (d ErrorWrapperDialer) DialContext(
ctx context.Context, network string, host string,
tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlySession, error) {
sess, err := d.Dialer.DialContext(ctx, network, host, tlsCfg, cfg)
err = errorx.SafeErrWrapperBuilder{
Classifier: errorx.ClassifyQUICFailure,
err = errorsx.SafeErrWrapperBuilder{
Classifier: errorsx.ClassifyQUICFailure,
Error: err,
Operation: errorx.QUICHandshakeOperation,
Operation: errorsx.QUICHandshakeOperation,
}.MaybeBuild()
if err != nil {
return nil, err
@@ -8,8 +8,8 @@ import (
"testing"
"github.com/lucas-clemente/quic-go"
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
"github.com/ooni/probe-cli/v3/internal/engine/netx/quicdialer"
"github.com/ooni/probe-cli/v3/internal/errorsx"
"github.com/ooni/probe-cli/v3/internal/netxlite"
)
@@ -22,21 +22,21 @@ func TestErrorWrapperFailure(t *testing.T) {
if sess != nil {
t.Fatal("expected a nil sess here")
}
errorWrapperCheckErr(t, err, errorx.QUICHandshakeOperation)
errorWrapperCheckErr(t, err, errorsx.QUICHandshakeOperation)
}
func errorWrapperCheckErr(t *testing.T, err error, op string) {
if !errors.Is(err, io.EOF) {
t.Fatal("expected another error here")
}
var errWrapper *errorx.ErrWrapper
var errWrapper *errorsx.ErrWrapper
if !errors.As(err, &errWrapper) {
t.Fatal("cannot cast to ErrWrapper")
}
if errWrapper.Operation != op {
t.Fatal("unexpected Operation")
}
if errWrapper.Failure != errorx.FailureEOFError {
if errWrapper.Failure != errorsx.FailureEOFError {
t.Fatal("unexpected failure")
}
}
@@ -61,7 +61,7 @@ func TestErrorWrapperInvalidCertificate(t *testing.T) {
if sess != nil {
t.Fatal("expected nil sess here")
}
if err.Error() != errorx.FailureSSLInvalidCertificate {
if err.Error() != errorsx.FailureSSLInvalidCertificate {
t.Fatal("unexpected failure")
}
}
+3 -3
View File
@@ -5,8 +5,8 @@ import (
"net"
"time"
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
"github.com/ooni/probe-cli/v3/internal/errorsx"
)
// QUICListener listens for QUIC connections.
@@ -53,7 +53,7 @@ func (c saverUDPConn) WriteTo(p []byte, addr net.Addr) (int, error) {
Duration: stop.Sub(start),
Err: err,
NumBytes: count,
Name: errorx.WriteToOperation,
Name: errorsx.WriteToOperation,
Time: stop,
})
return count, err
@@ -73,7 +73,7 @@ func (c saverUDPConn) ReadMsgUDP(b, oob []byte) (int, int, int, *net.UDPAddr, er
Duration: stop.Sub(start),
Err: err,
NumBytes: n,
Name: errorx.ReadFromOperation,
Name: errorsx.ReadFromOperation,
Time: stop,
})
return n, oobn, flags, addr, err
@@ -6,9 +6,9 @@ import (
"testing"
"github.com/lucas-clemente/quic-go"
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
"github.com/ooni/probe-cli/v3/internal/engine/netx/quicdialer"
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
"github.com/ooni/probe-cli/v3/internal/errorsx"
"github.com/ooni/probe-cli/v3/internal/netxlite"
)
@@ -49,7 +49,7 @@ func TestSystemDialerSuccessWithReadWrite(t *testing.T) {
t.Fatal("unexpected NumBytes")
}
switch ev[idx].Name {
case errorx.ReadFromOperation, errorx.WriteToOperation:
case errorsx.ReadFromOperation, errorsx.WriteToOperation:
default:
t.Fatal("unexpected Name")
}