|
cwist
Modern C web framework with libttak runtime
|
Unified error code and type definitions for the CWIST system layer. More...
#include <stdint.h>#include <stdbool.h>#include <cjson/cJSON.h>

Go to the source code of this file.
Classes | |
| struct | __prim_cwist_error_t |
| Internal union-like structure to store the actual error value. More... | |
| struct | cwist_error_t |
| Integrated error structure used throughout the system. More... | |
Macros | |
Common Status Codes | |
| #define | CWIST_SUCCESS 0 |
| #define | CWIST_FAILURE -1 |
| #define | CWIST_ERROR_IO -2 |
| #define | CWIST_ERROR_NOMEM -3 |
| #define | CWIST_ERROR_INVALID_PARAM -4 |
| #define | CWIST_ERROR_PROTOCOL -5 |
| #define | CWIST_ERROR_TIMEOUT -6 |
Typedefs | |
| typedef enum cwist_errtype_t | cwist_errtype_t |
| typedef struct __prim_cwist_error_t | __prim_cwist_error_t |
| typedef struct cwist_error_t | cwist_error_t |
Enumerations | |
| enum | cwist_errtype_t { CWIST_ERR_INT8 , CWIST_ERR_INT16 , CWIST_ERR_INT32 , CWIST_ERR_INT64 , CWIST_ERR_UINT8 , CWIST_ERR_UINT16 , CWIST_ERR_UINT32 , CWIST_ERR_UINT64 , CWIST_ERR_STRING , CWIST_ERR_JSON , CWIST_ERR_FLOAT , CWIST_ERR_DOUBLE } |
| Enumeration to identify the physical type of error data. More... | |
Functions | |
| cwist_error_t | make_error (cwist_errtype_t type) |
| Creates an error object initialized with the specified type. | |
| bool | cwist_error_is_ok_extern (const cwist_error_t *err) |
Out-of-line cwist_error_is_ok(), for callers that cannot use a static inline function, such as bindings generated from this header. | |
| void | cwist_error_dispose (cwist_error_t *err) |
| Release resources owned by an error value. Currently only CWIST_ERR_JSON owns memory (the cJSON payload); all other variants are no-ops. Safe on success values and on NULL. | |
Unified error code and type definitions for the CWIST system layer.
Definition in file cwist_err.h.
| #define CWIST_ERROR_INVALID_PARAM -4 |
Invalid argument passed to function
Definition at line 153 of file cwist_err.h.
| #define CWIST_ERROR_IO -2 |
I/O or Network level error (inc. SSL)
Definition at line 151 of file cwist_err.h.
| #define CWIST_ERROR_NOMEM -3 |
Memory allocation or resource exhaustion
Definition at line 152 of file cwist_err.h.
| #define CWIST_ERROR_PROTOCOL -5 |
Protocol-specific violation (HTTP/2, etc.)
Definition at line 154 of file cwist_err.h.
| #define CWIST_ERROR_TIMEOUT -6 |
Operation timed out
Definition at line 155 of file cwist_err.h.
| #define CWIST_FAILURE -1 |
Generic failure
Definition at line 150 of file cwist_err.h.
| #define CWIST_SUCCESS 0 |
Success (Standard OK)
Definition at line 149 of file cwist_err.h.
Enumeration to identify the physical type of error data.
Definition at line 22 of file cwist_err.h.
| void cwist_error_dispose | ( | cwist_error_t * | err | ) |
Release resources owned by an error value. Currently only CWIST_ERR_JSON owns memory (the cJSON payload); all other variants are no-ops. Safe on success values and on NULL.
Release resources owned by an error value. Currently only CWIST_ERR_JSON owns memory (the cJSON payload); all other variants are no-ops. Safe on success values and on NULL.
Currently only CWIST_ERR_JSON owns memory (the cJSON payload); all other variants are no-ops. Safe on success values and on NULL. The released cJSON pointer is reset to NULL, but the rest of the error value is left as-is.
| err | Error object to release (may be NULL). |
Definition at line 43 of file error.c.
References cap, and CWIST_ERR_JSON.
Referenced by cwist_assets_respond(), cwist_css_bundle(), cwist_css_minify(), cwist_css_scope_generate_stylesheet(), cwist_db_pool_create(), cwist_grpc_stream_send(), cwist_http_response_add_oob(), cwist_http_response_html_redirect(), and cwist_http_response_set_html().
| bool cwist_error_is_ok_extern | ( | const cwist_error_t * | err | ) |
Out-of-line cwist_error_is_ok(), for callers that cannot use a static inline function, such as bindings generated from this header.
Returns the same result as cwist_error_is_ok() for every input, including NULL (success) and an unknown errtype (failure).
| err | Error object to test (may be NULL). |
err represents success.Out-of-line cwist_error_is_ok(), for callers that cannot use a static inline function, such as bindings generated from this header.
Out-of-line cwist_error_is_ok(); see include/cwist/sys/err/cwist_err.h.
Forwards to the inline helper so the two can never disagree. Success means the active channel holds its zero/empty value; NULL counts as success and an unknown errtype counts as failure.
| err | Error object to test (may be NULL). |
err represents success. | cwist_error_t make_error | ( | cwist_errtype_t | type | ) |
Creates an error object initialized with the specified type.
| type | The type of error to create (cwist_errtype_t) |
Creates an error object initialized with the specified type.
| type | Error payload discriminator to store in the result. |
errtype set and the payload left for the caller to fill.