Errors

Many NNG functions can fail for a variety of reasons. These functions tend to return either zero on success, or a non-zero error code to indicate failure. 1

All these error codes are int.

Not every possible error code is defined here, as sometimes an underlying system or library error code is “wrapped”.

Human Readable Error Message

const char *nng_strerror(int err);

The nng_strerror returns the human-readable description of the given error in err.

The error message returned is a fixed NUL-terminated string and may be located in read-only memory.

The returned error message is provided in US English, but in the future locale-specific strings may be presented instead.

note

The specific strings associated with specific error messages are subject to change. Therefore applications must not depend on the message, but may use them verbatim when supplying information to end-users, such as in diagnostic messages or log entries.

List of Errors

ErrorValueDescription
NNG_EINTR1Operation interrupted.
NNG_ENOMEM2Out of memory, or other resource exahusted.
NNG_EINVAL3Invalid argument. The arguments are invalid or malformed somehow.
NNG_EBUSY4Resource busy.
NNG_ETIMEDOUT5Timed out. The operation took longer than the allotted time.
NNG_ECONNREFUSED6Connection refused. Usually indicates the wrong address or a server is running.
NNG_ECLOSED7Object closed. Typically the socket is closed.
NNG_EAGAIN8Try again. Typcally for a non-blocking operation that might succeed later.
NNG_ENOTSUP9Not supported. Perhaps the protocol or transport is not supported, or the operation is not not supported with the transport or protocol.
NNG_EADDRINUSE10Address in use. The network address is already used by another process. Most often this is seen for listeners.
NNG_ESTATE11Incorrect state. The operation cannot be performed in the current state, such as trying to send a response when no request has yet been received.
NNG_ENOENT12Entry not found (no such object.) Can also indicate that a file does not exist.
NNG_EPROTO13Protocol error. Typically this indicates incorrect messages over a network.
NNG_EUNREACHABLE14Destination unreachable.
NNG_EADDRINVAL15Address invalid. Like NNG_EINVAL, but only for network addresses.
NNG_EPERM16Permission denied.
NNG_EMSGSIZE17Message too large.
NNG_ECONNABORTED18Connection aborted. A connection attempt was aborted locally.
NNG_ECONNRESET19Connection reset. The remote peer reset the connection unexpectedly.
NNG_ECANCELED20Operation canceled. Typically as a result of nng_aio_cancel or similar.
NNG_ENOFILES21Out of files. Either the destination file system cannot store files, or all available file handles are used.
NNG_ENOSPC22Out of space. Destination table or filesystem is full.
NNG_EEXIST23Resource already exists.
NNG_EREADONLY24Read only resource. An attempt to modify a read-only file or other object.
NNG_EWRITEONLY25Write only resource. A read operation failed because the object only supports writes.
NNG_ECRYPTO26Cryptographic error. Usually indicates an invalid key was used for TLS.
NNG_EPEERAUTH27Peer could not be authenticated.
NNG_ENOARG28Option requires argument. A command-line option was supplied without an argument. Only used with nng_opts_parse.
NNG_EAMBIGUOUS29Ambiguous option. The command line option could not be unambiguously resolved. Only used with nng_opts_parse.
NNG_EBADTYPE30Incorrect type. A type-specific function was used for an object of the wrong type.
NNG_ECONNSHUT31Connection shutdown. The connection was shut down and cannot be used.
NNG_EINTERNAL1000An unidentifier internal error occurred.
NNG_ESYSERR0x10000000 - 0x1FFFFFFFAn unidentified system error occurred. These are errors reported by the operating system.
NNG_ETRANERR0x20000000 - 0x2FFFFFFFAn unidentified transport error occurred.


1: This convention goes back to UNIX system calls, which behave the same way, but NNG does not use a separate errno variable.