8b38ea7e98
No functional change, as it's clearly obvious from the output. While there, also rename the generator for certifi. We are planning on merging errorsx into netxlite. The first step is to give different names to the code generating programs. See https://github.com/ooni/probe/issues/1591
120 lines
3.9 KiB
Go
120 lines
3.9 KiB
Go
// Code generated by go generate; DO NOT EDIT.
|
|
// Generated: 2021-09-07 13:05:58.447943 +0200 CEST m=+0.137110292
|
|
|
|
package errorsx
|
|
|
|
//go:generate go run ./generator/
|
|
|
|
import (
|
|
"errors"
|
|
"syscall"
|
|
)
|
|
|
|
// 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"
|
|
)
|
|
|
|
// 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:
|
|
return FailureOperationCanceled
|
|
case ECONNREFUSED:
|
|
return FailureConnectionRefused
|
|
case ECONNRESET:
|
|
return FailureConnectionReset
|
|
case EHOSTUNREACH:
|
|
return FailureHostUnreachable
|
|
case ETIMEDOUT:
|
|
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
|
|
}
|
|
return ""
|
|
}
|