<cahute/error.h> – Error definitions for Cahute

This header declares error values and utilities for Cahute.

Macro definitions

CAHUTE_OK

Error returned in case of success. This is set to 0, so that in order to check if a Cahute function has yielded an error, you can do the following:

if (cahute_do_thing(1, 2)) {
    fprintf(stderr, "An error has occurred.\n");
    return EXIT_FAILURE;
}
CAHUTE_ERROR_UNKNOWN

Error raised if the cause of the error is unknown.

The logs can be investigated for more information.

CAHUTE_ERROR_IMPL

Error raised if a required feature or code path was unimplemented.

CAHUTE_ERROR_ALLOC

Error raised if a memory allocation has failed.

CAHUTE_ERROR_PRIV

Error raised if a system privilege error has been encountered.

CAHUTE_ERROR_INT

Error raised if, for a function taking a callback and calling it with every iteration, said callback has returned 1 on a given iteration, meaning the iteration was INTerrupted.

CAHUTE_ERROR_SIZE

Error raised if an incoming message was too big for the corresponding internal buffers.

CAHUTE_ERROR_TRUNC

Error raised when the source data was incomplete or truncated.

CAHUTE_ERROR_INVALID

Error raised when the source data was invalid.

CAHUTE_ERROR_INCOMPAT

Error raised if:

  • A device was not suitable to be opened to be used by a link.

  • An input buffer contained a character that had no equivalent in the destination encoding.

CAHUTE_ERROR_TERMINATED

Error raised if:

  • A connection to a device over a link has been terminated, and the requested operation is therefore not possible.

  • An input buffer contained a sentinel, for text conversion.

CAHUTE_ERROR_NOT_FOUND

Error code raised if a device could not be found using the provided identification (name, path, or bus identification).

CAHUTE_ERROR_TOO_MANY

Error raised if only a single device was expected, but multiple were found.

CAHUTE_ERROR_GONE

Error raised if a device with which communication was previously established is no longer accessible.

CAHUTE_ERROR_TIMEOUT_START

Error raised if a read timeout has been encountered on the start of a block, e.g. at the start of a packet.

CAHUTE_ERROR_TIMEOUT

Error raised if a read timeout has been encountered within or at the end of a block, e.g. within or at the end of a packet.

CAHUTE_ERROR_CORRUPT

Error raised if an incoming packet had invalid format, or an invalid checksum.

CAHUTE_ERROR_IRRECOV

Error raised if the link was previously deemed irrecoverable, and as such, the current operation could not be executed.

CAHUTE_ERROR_NOOW

Error raised if overwrite was requested and rejected by either us or the calculator.

Function declarations

char const *cahute_get_error_name(int code)

Get the name of the constant corresponding to the given error code, in ASCII, using only capital letters, decimal digits and low lines (underscores).

Parameters:
  • code – Code for which to get the error name.

Returns:

Name of the error code, in ASCII.