Skip to content

Errors API

Error codes and error handling.

Types

c
typedef enum fq_status_t {
    FQ_OK            =  0,
    FQ_ERR_NOMEM     = -1,
    FQ_ERR_INVAL     = -2,
    FQ_ERR_BUSY      = -3,
    FQ_ERR_TIMEOUT   = -4,
    FQ_ERR_CANCELED  = -5,
    FQ_ERR_OVERFLOW  = -6,
    FQ_ERR_CLOSED    = -7,
    FQ_ERR_INTERNAL  = -8,
    FQ_ERR_NOSUPPORT = -9
} fq_status_t;

Functions

c
const char *fq_status_string(fq_status_t status);

Get human-readable error string for a status code.

c
fq_bool_t fq_status_ok(fq_status_t status);

Check whether a status code indicates success (FQ_TRUE if FQ_OK).

c
const char *fq_last_error(void);

Get the thread-local error message from the last failed operation. Returns an empty string if no error.

c
void fq_set_error(const char *fmt, ...);

Set the thread-local error message with a printf-style format string.

Error Codes

CodeNameDescription
0FQ_OKSuccess
-1FQ_ERR_NOMEMOut of memory
-2FQ_ERR_INVALInvalid argument
-3FQ_ERR_BUSYResource busy / would block
-4FQ_ERR_TIMEOUTOperation timed out
-5FQ_ERR_CANCELEDOperation was canceled
-6FQ_ERR_OVERFLOWQueue is full
-7FQ_ERR_CLOSEDSystem has been shut down
-8FQ_ERR_INTERNALInternal error
-9FQ_ERR_NOSUPPORTOperation not supported

Example

c
fq_status_t st = fq_thread_pool_create_ex(&pool, 4);
if (!fq_status_ok(st)) {
    fprintf(stderr, "Failed to create pool: %s (code=%d)\n",
            fq_status_string(st), st);
    return 1;
}

Released under the MIT License.