refactor(errorsx): prepare for splitting the package (#476)
We will move the sane part of this package to i/netxlite/errorsx and we will move the rest to i/e/legacy/errorsx. What is the sane part? The sane part is error classifiers plus the definition of ErrWrapper. The rest, including the rules on how to decide whether an operation is major, are tricky and we should consider them legacy and replace them with rules that are more easy to understand and reason on. Part of https://github.com/ooni/probe/issues/1591
This commit is contained in:
parent
cef801fa23
commit
ccb3a644e1
11 changed files with 96 additions and 90 deletions
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// Generated: 2021-09-07 14:56:43.25305 +0200 CEST m=+0.187989417
|
||||
// Generated: 2021-09-07 15:15:03.398087 +0200 CEST m=+0.183158793
|
||||
|
||||
package errorsx
|
||||
|
||||
|
|
@ -10,94 +10,94 @@ import (
|
|||
)
|
||||
|
||||
func TestToSyscallErr(t *testing.T) {
|
||||
if v := toSyscallErr(io.EOF); v != "" {
|
||||
if v := classifySyscallError(io.EOF); v != "" {
|
||||
t.Fatalf("expected empty string, got '%s'", v)
|
||||
}
|
||||
if v := toSyscallErr(ECANCELED); v != FailureOperationCanceled {
|
||||
if v := classifySyscallError(ECANCELED); v != FailureOperationCanceled {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureOperationCanceled, v)
|
||||
}
|
||||
if v := toSyscallErr(ECONNREFUSED); v != FailureConnectionRefused {
|
||||
if v := classifySyscallError(ECONNREFUSED); v != FailureConnectionRefused {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureConnectionRefused, v)
|
||||
}
|
||||
if v := toSyscallErr(ECONNRESET); v != FailureConnectionReset {
|
||||
if v := classifySyscallError(ECONNRESET); v != FailureConnectionReset {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureConnectionReset, v)
|
||||
}
|
||||
if v := toSyscallErr(EHOSTUNREACH); v != FailureHostUnreachable {
|
||||
if v := classifySyscallError(EHOSTUNREACH); v != FailureHostUnreachable {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureHostUnreachable, v)
|
||||
}
|
||||
if v := toSyscallErr(ETIMEDOUT); v != FailureTimedOut {
|
||||
if v := classifySyscallError(ETIMEDOUT); v != FailureTimedOut {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureTimedOut, v)
|
||||
}
|
||||
if v := toSyscallErr(EAFNOSUPPORT); v != FailureAddressFamilyNotSupported {
|
||||
if v := classifySyscallError(EAFNOSUPPORT); v != FailureAddressFamilyNotSupported {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureAddressFamilyNotSupported, v)
|
||||
}
|
||||
if v := toSyscallErr(EADDRINUSE); v != FailureAddressInUse {
|
||||
if v := classifySyscallError(EADDRINUSE); v != FailureAddressInUse {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureAddressInUse, v)
|
||||
}
|
||||
if v := toSyscallErr(EADDRNOTAVAIL); v != FailureAddressNotAvailable {
|
||||
if v := classifySyscallError(EADDRNOTAVAIL); v != FailureAddressNotAvailable {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureAddressNotAvailable, v)
|
||||
}
|
||||
if v := toSyscallErr(EISCONN); v != FailureAlreadyConnected {
|
||||
if v := classifySyscallError(EISCONN); v != FailureAlreadyConnected {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureAlreadyConnected, v)
|
||||
}
|
||||
if v := toSyscallErr(EFAULT); v != FailureBadAddress {
|
||||
if v := classifySyscallError(EFAULT); v != FailureBadAddress {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureBadAddress, v)
|
||||
}
|
||||
if v := toSyscallErr(EBADF); v != FailureBadFileDescriptor {
|
||||
if v := classifySyscallError(EBADF); v != FailureBadFileDescriptor {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureBadFileDescriptor, v)
|
||||
}
|
||||
if v := toSyscallErr(ECONNABORTED); v != FailureConnectionAborted {
|
||||
if v := classifySyscallError(ECONNABORTED); v != FailureConnectionAborted {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureConnectionAborted, v)
|
||||
}
|
||||
if v := toSyscallErr(EALREADY); v != FailureConnectionAlreadyInProgress {
|
||||
if v := classifySyscallError(EALREADY); v != FailureConnectionAlreadyInProgress {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureConnectionAlreadyInProgress, v)
|
||||
}
|
||||
if v := toSyscallErr(EDESTADDRREQ); v != FailureDestinationAddressRequired {
|
||||
if v := classifySyscallError(EDESTADDRREQ); v != FailureDestinationAddressRequired {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureDestinationAddressRequired, v)
|
||||
}
|
||||
if v := toSyscallErr(EINTR); v != FailureInterrupted {
|
||||
if v := classifySyscallError(EINTR); v != FailureInterrupted {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureInterrupted, v)
|
||||
}
|
||||
if v := toSyscallErr(EINVAL); v != FailureInvalidArgument {
|
||||
if v := classifySyscallError(EINVAL); v != FailureInvalidArgument {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureInvalidArgument, v)
|
||||
}
|
||||
if v := toSyscallErr(EMSGSIZE); v != FailureMessageSize {
|
||||
if v := classifySyscallError(EMSGSIZE); v != FailureMessageSize {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureMessageSize, v)
|
||||
}
|
||||
if v := toSyscallErr(ENETDOWN); v != FailureNetworkDown {
|
||||
if v := classifySyscallError(ENETDOWN); v != FailureNetworkDown {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureNetworkDown, v)
|
||||
}
|
||||
if v := toSyscallErr(ENETRESET); v != FailureNetworkReset {
|
||||
if v := classifySyscallError(ENETRESET); v != FailureNetworkReset {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureNetworkReset, v)
|
||||
}
|
||||
if v := toSyscallErr(ENETUNREACH); v != FailureNetworkUnreachable {
|
||||
if v := classifySyscallError(ENETUNREACH); v != FailureNetworkUnreachable {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureNetworkUnreachable, v)
|
||||
}
|
||||
if v := toSyscallErr(ENOBUFS); v != FailureNoBufferSpace {
|
||||
if v := classifySyscallError(ENOBUFS); v != FailureNoBufferSpace {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureNoBufferSpace, v)
|
||||
}
|
||||
if v := toSyscallErr(ENOPROTOOPT); v != FailureNoProtocolOption {
|
||||
if v := classifySyscallError(ENOPROTOOPT); v != FailureNoProtocolOption {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureNoProtocolOption, v)
|
||||
}
|
||||
if v := toSyscallErr(ENOTSOCK); v != FailureNotASocket {
|
||||
if v := classifySyscallError(ENOTSOCK); v != FailureNotASocket {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureNotASocket, v)
|
||||
}
|
||||
if v := toSyscallErr(ENOTCONN); v != FailureNotConnected {
|
||||
if v := classifySyscallError(ENOTCONN); v != FailureNotConnected {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureNotConnected, v)
|
||||
}
|
||||
if v := toSyscallErr(EWOULDBLOCK); v != FailureOperationWouldBlock {
|
||||
if v := classifySyscallError(EWOULDBLOCK); v != FailureOperationWouldBlock {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureOperationWouldBlock, v)
|
||||
}
|
||||
if v := toSyscallErr(EACCES); v != FailurePermissionDenied {
|
||||
if v := classifySyscallError(EACCES); v != FailurePermissionDenied {
|
||||
t.Fatalf("expected '%s', got '%s'", FailurePermissionDenied, v)
|
||||
}
|
||||
if v := toSyscallErr(EPROTONOSUPPORT); v != FailureProtocolNotSupported {
|
||||
if v := classifySyscallError(EPROTONOSUPPORT); v != FailureProtocolNotSupported {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureProtocolNotSupported, v)
|
||||
}
|
||||
if v := toSyscallErr(EPROTOTYPE); v != FailureWrongProtocolType {
|
||||
if v := classifySyscallError(EPROTOTYPE); v != FailureWrongProtocolType {
|
||||
t.Fatalf("expected '%s', got '%s'", FailureWrongProtocolType, v)
|
||||
}
|
||||
if v := toSyscallErr(syscall.Errno(0)); v != "" {
|
||||
if v := classifySyscallError(syscall.Errno(0)); v != "" {
|
||||
t.Fatalf("expected empty string, got '%s'", v)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue