2021-07-02 15:22:02 +02:00
|
|
|
// Code generated by go generate; DO NOT EDIT.
|
2021-09-05 14:49:38 +02:00
|
|
|
// Generated: 2021-09-05 13:54:14.649711 +0200 CEST m=+0.136980959
|
2021-07-02 15:22:02 +02:00
|
|
|
|
|
|
|
package errorsx
|
|
|
|
|
|
|
|
//go:generate go run ./generator/
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"syscall"
|
|
|
|
)
|
|
|
|
|
2021-07-08 12:23:37 +02:00
|
|
|
// This enumeration lists the syscall-derived failures defined at
|
|
|
|
// https://github.com/ooni/spec/blob/master/data-formats/df-007-errors.md
|
|
|
|
//
|
|
|
|
// See also the enumeration at failures.go for the failures that
|
|
|
|
// DO NOT derive from system call errors.
|
|
|
|
const (
|
|
|
|
FailureOperationCanceled = "operation_canceled"
|
|
|
|
FailureConnectionRefused = "connection_refused"
|
|
|
|
FailureConnectionReset = "connection_reset"
|
|
|
|
FailureHostUnreachable = "host_unreachable"
|
|
|
|
FailureTimedOut = "timed_out"
|
|
|
|
FailureAddressFamilyNotSupported = "address_family_not_supported"
|
|
|
|
FailureAddressInUse = "address_in_use"
|
|
|
|
FailureAddressNotAvailable = "address_not_available"
|
|
|
|
FailureAlreadyConnected = "already_connected"
|
|
|
|
FailureBadAddress = "bad_address"
|
|
|
|
FailureBadFileDescriptor = "bad_file_descriptor"
|
|
|
|
FailureConnectionAborted = "connection_aborted"
|
|
|
|
FailureConnectionAlreadyInProgress = "connection_already_in_progress"
|
|
|
|
FailureDestinationAddressRequired = "destination_address_required"
|
|
|
|
FailureInterrupted = "interrupted"
|
|
|
|
FailureInvalidArgument = "invalid_argument"
|
|
|
|
FailureMessageSize = "message_size"
|
|
|
|
FailureNetworkDown = "network_down"
|
|
|
|
FailureNetworkReset = "network_reset"
|
|
|
|
FailureNetworkUnreachable = "network_unreachable"
|
|
|
|
FailureNoBufferSpace = "no_buffer_space"
|
|
|
|
FailureNoProtocolOption = "no_protocol_option"
|
|
|
|
FailureNotASocket = "not_a_socket"
|
|
|
|
FailureNotConnected = "not_connected"
|
|
|
|
FailureOperationWouldBlock = "operation_would_block"
|
|
|
|
FailurePermissionDenied = "permission_denied"
|
|
|
|
FailureProtocolNotSupported = "protocol_not_supported"
|
|
|
|
FailureWrongProtocolType = "wrong_protocol_type"
|
|
|
|
)
|
|
|
|
|
2021-07-02 15:22:02 +02:00
|
|
|
// toSyscallErr converts a syscall error to the
|
|
|
|
// proper OONI error. Returns the OONI error string
|
|
|
|
// on success, an empty string otherwise.
|
|
|
|
func toSyscallErr(err error) string {
|
|
|
|
// filter out system errors: necessary to detect all windows errors
|
|
|
|
// https://github.com/ooni/probe/issues/1526 describes the problem
|
|
|
|
// of mapping localized windows errors.
|
|
|
|
var errno syscall.Errno
|
|
|
|
if !errors.As(err, &errno) {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
switch errno {
|
|
|
|
case ECANCELED:
|
2021-07-08 12:23:37 +02:00
|
|
|
return FailureOperationCanceled
|
2021-07-02 15:22:02 +02:00
|
|
|
case ECONNREFUSED:
|
|
|
|
return FailureConnectionRefused
|
|
|
|
case ECONNRESET:
|
|
|
|
return FailureConnectionReset
|
|
|
|
case EHOSTUNREACH:
|
|
|
|
return FailureHostUnreachable
|
|
|
|
case ETIMEDOUT:
|
2021-07-08 12:23:37 +02:00
|
|
|
return FailureTimedOut
|
|
|
|
case EAFNOSUPPORT:
|
|
|
|
return FailureAddressFamilyNotSupported
|
|
|
|
case EADDRINUSE:
|
|
|
|
return FailureAddressInUse
|
|
|
|
case EADDRNOTAVAIL:
|
|
|
|
return FailureAddressNotAvailable
|
|
|
|
case EISCONN:
|
|
|
|
return FailureAlreadyConnected
|
|
|
|
case EFAULT:
|
|
|
|
return FailureBadAddress
|
|
|
|
case EBADF:
|
|
|
|
return FailureBadFileDescriptor
|
|
|
|
case ECONNABORTED:
|
|
|
|
return FailureConnectionAborted
|
|
|
|
case EALREADY:
|
|
|
|
return FailureConnectionAlreadyInProgress
|
|
|
|
case EDESTADDRREQ:
|
|
|
|
return FailureDestinationAddressRequired
|
|
|
|
case EINTR:
|
|
|
|
return FailureInterrupted
|
|
|
|
case EINVAL:
|
|
|
|
return FailureInvalidArgument
|
|
|
|
case EMSGSIZE:
|
|
|
|
return FailureMessageSize
|
|
|
|
case ENETDOWN:
|
|
|
|
return FailureNetworkDown
|
|
|
|
case ENETRESET:
|
|
|
|
return FailureNetworkReset
|
|
|
|
case ENETUNREACH:
|
|
|
|
return FailureNetworkUnreachable
|
|
|
|
case ENOBUFS:
|
|
|
|
return FailureNoBufferSpace
|
|
|
|
case ENOPROTOOPT:
|
|
|
|
return FailureNoProtocolOption
|
|
|
|
case ENOTSOCK:
|
|
|
|
return FailureNotASocket
|
|
|
|
case ENOTCONN:
|
|
|
|
return FailureNotConnected
|
|
|
|
case EWOULDBLOCK:
|
|
|
|
return FailureOperationWouldBlock
|
|
|
|
case EACCES:
|
|
|
|
return FailurePermissionDenied
|
|
|
|
case EPROTONOSUPPORT:
|
|
|
|
return FailureProtocolNotSupported
|
|
|
|
case EPROTOTYPE:
|
|
|
|
return FailureWrongProtocolType
|
2021-07-02 15:22:02 +02:00
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|