Data Structures | |
struct | mirkl_error_t_ |
Structure of error object. More... | |
Macros | |
#define | MIRKL_NO_ERROR NULL |
The best kind of (mirkl_error_t *) ! | |
#define | mirkl_error_create(err_code, child, msg) (mirkl_error_create_i(MIRKL_ERRT_NORMAL,err_code,0,NULL,NULL,child,msg)) |
Wrapper macro to collect file&line and func information. | |
#define | mirkl_error_create_t(type, err_code, child, msg) (mirkl_error_create_i(type,err_code,0,NULL,NULL,child,msg)) |
Wrapper macro which allows to define the type of error. | |
#define | mirkl_error_createf(err_code, child, fmt, ...) (mirkl_error_createf_i(MIRKL_ERRT_NORMAL,err_code,0,NULL,NULL,child,fmt, __VA_ARGS__)) |
Wrapper macro to collect file&line and func information. | |
#define | mirkl_error_createf_t(type, err_code, child, fmt, ...) (mirkl_error_createf_i(type,err_code,0,NULL,NULL,child,fmt, __VA_ARGS__)) |
Wrapper macro which allows to define the type of error. | |
#define | mirkl_error_aprwrap(status) (mirkl_error_aprwrap_i(status,0,NULL,NULL)) |
Wrapper macro to collect file&line and func information. | |
#define | mirkl_error_aprwrapf(status, fmt, ...) (mirkl_error_aprwrapf_i(status,0,NULL,NULL,fmt, __VA_ARGS__)) |
Wrapper macro to collect file&line and func information. | |
#define | mirkl_error_quick_wrap(child, new_msg) (mirkl_error_quick_wrap_i(0,NULL,NULL,child,new_msg)) |
Wrapper macro to collect file&line and func information. | |
#define | MIRKL_WARNING(msg) (mirkl_error_clear(mirkl_error_handle(mirkl_error_create_t(MIRKL_ERRT_WARNING,0,NULL,msg), mirkl_error_stdhandler, (void *)stdout))) |
Typedefs | |
typedef struct mirkl_error_t_ | mirkl_error_t |
Structure of error object. | |
typedef void(* | mirkl_error_malfunction_handler_t) (mirkl_error_t *error) |
A type of function that handles an assertion failure or other internal malfunction detected. More... | |
Functions | |
void | mirkl_error_set_type (mirkl_error_t *error, int type) |
Sets type of an error to type. | |
void | mirkl_error_set_type_all (mirkl_error_t *error, int type) |
Sets type of an error and all of its childs to type. | |
mirkl_error_t * | mirkl_error_create_i (int err_type, int err_code, int line, const char *file, const char *func, mirkl_error_t *child, const char *message) |
Create a nested exception structure. More... | |
mirkl_error_t * | mirkl_error_createf_i (int err_type, int err_code, int line, const char *file, const char *func, mirkl_error_t *child, const char *fmt,...) __attribute__((format(printf |
mirkl_error_t * | mirkl_error_aprwrap_i (apr_status_t status, int line, const char *file, const char *func) |
mirkl_error_t * | mirkl_error_aprwrapf_i (apr_status_t status, int line, const char *file, const char *func, const char *fmt,...) __attribute__((format(printf |
mirkl_error_t * | mirkl_error_quick_wrap_i (int line, const char *file, const char *func, mirkl_error_t *child, const char *new_msg) |
mirkl_error_t * | mirkl_error_compose_create (mirkl_error_t *err1, mirkl_error_t *err2) |
void | mirkl_error_compose (mirkl_error_t *chain, mirkl_error_t *new_err) |
mirkl_error_t * | mirkl_error_root_cause (mirkl_error_t *err) |
mirkl_error_t * | mirkl_error_dup (mirkl_error_t *err) |
Create a new error that is a deep copy of err and return it. | |
void | mirkl_error_clear (mirkl_error_t *error) |
Free the memory used by error, as well as all ancestors and descendants of error. More... | |
mirkl_error_t * | mirkl_error_handle (mirkl_error_t *err, void(*errhcb)(const char *, void *), void *args) |
void | mirkl_error_stdhandler (const char *msg, void *args) |
void | mirkl_error_walk (mirkl_error_t *err, void(*cb)(int, const char *, const char *, mirkl_uint32_t, const char *, void *), void *args) |
mirkl_error_t * | mirkl_error_register (int *code, const char *msg) |
mirkl_error_t * | mirkl_error_deregister (int code) |
void | mirkl_error_malfunction (mirkl_error_t *error) |
A helper function for the macros that report malfunctions. More... | |
mirkl_error_malfunction_handler_t | mirkl_error_set_malfunction_handler (mirkl_error_malfunction_handler_t func) |
Cause subsequent malfunctions to be handled by func. More... | |
mirkl_error_malfunction_handler_t | mirkl_error_get_malfunction_handler (void) |
Return the malfunction handler that is currently in effect. | |
void | mirkl_error_serialize (mirkl_error_t *error, void **buffer, mirkl_size_t *length) |
Serialize an error to buffer. More... | |
void | mirkl_error_deserialize (mirkl_error_t **error, void *buffer, mirkl_size_t length) |
DeSerialize an error to buffer. More... | |
mirkl_uint16_t | mirkl_error_crc16 (mirkl_error_t *error) |
Calculate CRC16 of an error. | |
void | mirkl_error_set_data (mirkl_error_t *err, void *data) |
Set user-defined data to the error. | |
void * | mirkl_error_get_data (mirkl_error_t *err) |
Get previously defined data from the error. | |
void * | mirkl_error_get_data_first (mirkl_error_t *err) |
Look-up the chain of errors and get first non-NULL data pointer. | |
Variables | |
mirkl_error_t * | MirklDLlistStopWalking |
Statement macros for checking error values | |
#define | MIRKL_ERR(expr) |
Most basic macro for checking for errors. More... | |
#define | MIRKL_ERR_ABORT(expr) |
Calls standard error handler and aborts program if expr returns an error. More... | |
#define | MIRKL_ERR_NC(expr, code) |
Returns error only if it is not equal to code. More... | |
#define | MIRKL_ERR_NCDO(expr, code, doexpr) |
Returns error only if it is not equal to code, otherwise frees the error and executes doexpr expression. More... | |
#define | MIRKL_ERR_EXE(expr, exexpr) |
Before returning error executes expression. More... | |
#define | MIRKL_ERR_NCDO_EXE(expr, code, doexpr, exexpr) |
Returns error (after executing exexpr expression) only if it is not equal to code, otherwise frees the error and executes doexpr expression. More... | |
#define | MIRKL_ERR_W(expr, wrap_msg) |
This macro will wrap the error with the specified text before returning the error. More... | |
#define | MIRKL_ERR_NC_W(expr, code, wrap_msg) |
Wraps text message and returns error only if it is not equal to code. More... | |
#define | MIRKL_ERR_EXE_W(expr, exexpr, wrap_msg) |
Does same as MIRKL_ERR_W but also executes expression exexpr. More... | |
#define | MIRKL_ERR_NC_EXE_W(expr, code, exexpr, wrap_msg) |
Does same as MIRKL_ERR_NC_W but also executes expression exexpr. More... | |
#define | MIRKL_ERR_INT(expr, retint) |
A statement macro, similar to MIRKL_ERR, but returns integer instead of pointer to mirkl_error_t . More... | |
#define | MIRKL_ERR_E(expr, err) |
If execution of expr returned and error, appends err and returns common error. More... | |
#define | MIRKL_ERR_E_W(expr, err, msg) |
Works as MIRKL_ERR_E and wraps additionally msg string. More... | |
#define | MIRKL_ERR_E_GOTO(expr, err, labl) |
If execution of expr returned an error, appends err and jumps to labl label. More... | |
#define | MIRKL_ERR_E_W_GOTO(expr, err, msg, labl) |
Works as MIRKL_ERR_E_GOTO and wraps additionally msg string. More... | |
Abnormal process termination | |
#define | MIRKL_ASSERT(expr) ((void)(0)) |
Check that a condition is true: if not, report an error and terminate the program. More... | |
#define | MIRKL_ASSERT_W(expr, msg) ((void)(0)) |
Similar to MIRKL_ASSERT but also allows to add user message msg. | |
#define | MIRKL_ASSERT_E(expr, err) ((void)(0)) |
Similar to MIRKL_ASSERT but also allows to add an error err. | |
#define | MIRKL_MALFUNCTION() |
Report that an internal malfunction has occurred, and terminate the program. More... | |
#define | MIRKL_ABORT() |
Same as MIRKL_MALFUNCTION. More... | |
#define | MIRKL_ABORT_E(err) |
Similar to MIRKL_ABORT but also takes info from error err. More... | |
#define | MIRKL_ABORT_W(msg) |
Similar to MIRKL_ABORT but also takes info from string msg. More... | |
#define | MIRKL_ABORT_E_W(err, msg) |
Similar to MIRKL_ABORT but also takes err as a child error and info from string msg. More... | |
Part of the code and ideas have been taken from Subversion project.
#define MIRKL_ABORT | ( | ) |
Same as MIRKL_MALFUNCTION.
#define MIRKL_ABORT_E | ( | err | ) |
Similar to MIRKL_ABORT but also takes info from error err.
#define MIRKL_ABORT_E_W | ( | err, | |
msg | |||
) |
Similar to MIRKL_ABORT but also takes err as a child error and info from string msg.
#define MIRKL_ABORT_W | ( | msg | ) |
Similar to MIRKL_ABORT but also takes info from string msg.
#define MIRKL_ASSERT | ( | expr | ) | ((void)(0)) |
Check that a condition is true: if not, report an error and terminate the program.
If the Boolean expression expr is true, do nothing. Otherwise, act as determined by the current "malfunction handler" which may have been specified by a call to mirkl_error_set_malfunction_handler() or else is the default handler as specified in that function's documentation.
#define MIRKL_ERR | ( | expr | ) |
Most basic macro for checking for errors.
Evaluate expr. If it yields an error, return that error from the current function. Otherwise, continue.
The do { ... } while (0)
wrapper has no semantic effect, but it makes this macro syntactically equivalent to the expression statement it resembles. Without it, statements like
would not mean what they appear to.
#define MIRKL_ERR_ABORT | ( | expr | ) |
Calls standard error handler and aborts program if expr returns an error.
#define MIRKL_ERR_E | ( | expr, | |
err | |||
) |
If execution of expr returned and error, appends err and returns common error.
#define MIRKL_ERR_E_GOTO | ( | expr, | |
err, | |||
labl | |||
) |
If execution of expr returned an error, appends err and jumps to labl label.
#define MIRKL_ERR_E_W | ( | expr, | |
err, | |||
msg | |||
) |
Works as MIRKL_ERR_E and wraps additionally msg string.
#define MIRKL_ERR_E_W_GOTO | ( | expr, | |
err, | |||
msg, | |||
labl | |||
) |
Works as MIRKL_ERR_E_GOTO and wraps additionally msg string.
#define MIRKL_ERR_EXE | ( | expr, | |
exexpr | |||
) |
Before returning error executes expression.
#define MIRKL_ERR_EXE_W | ( | expr, | |
exexpr, | |||
wrap_msg | |||
) |
Does same as MIRKL_ERR_W but also executes expression exexpr.
#define MIRKL_ERR_INT | ( | expr, | |
retint | |||
) |
A statement macro, similar to MIRKL_ERR, but returns integer instead of pointer to mirkl_error_t
.
#define MIRKL_ERR_NC | ( | expr, | |
code | |||
) |
Returns error only if it is not equal to code.
#define MIRKL_ERR_NC_EXE_W | ( | expr, | |
code, | |||
exexpr, | |||
wrap_msg | |||
) |
Does same as MIRKL_ERR_NC_W but also executes expression exexpr.
#define MIRKL_ERR_NC_W | ( | expr, | |
code, | |||
wrap_msg | |||
) |
Wraps text message and returns error only if it is not equal to code.
#define MIRKL_ERR_NCDO | ( | expr, | |
code, | |||
doexpr | |||
) |
Returns error only if it is not equal to code, otherwise frees the error and executes doexpr expression.
#define MIRKL_ERR_NCDO_EXE | ( | expr, | |
code, | |||
doexpr, | |||
exexpr | |||
) |
Returns error (after executing exexpr expression) only if it is not equal to code, otherwise frees the error and executes doexpr expression.
#define MIRKL_ERR_W | ( | expr, | |
wrap_msg | |||
) |
This macro will wrap the error with the specified text before returning the error.
#define MIRKL_MALFUNCTION | ( | ) |
Report that an internal malfunction has occurred, and terminate the program.
Act as determined by the current "malfunction handler" which may have been specified by a call to mirkl_error_set_malfunction_handler() or else is the default handler as specified in that function's documentation.
#define MIRKL_WARNING | ( | msg | ) | (mirkl_error_clear(mirkl_error_handle(mirkl_error_create_t(MIRKL_ERRT_WARNING,0,NULL,msg), mirkl_error_stdhandler, (void *)stdout))) |
Macro to print warning messages.
typedef void(* mirkl_error_malfunction_handler_t) (mirkl_error_t *error) |
A type of function that handles an assertion failure or other internal malfunction detected.
The function may alter thi behaviour according to compile-time and run-time and even interactive conditions.
mirkl_error_t * mirkl_error_aprwrap_i | ( | apr_status_t | status, |
int | line, | ||
const char * | file, | ||
const char * | func | ||
) |
Create error wrapping status code from an APR function.
mirkl_error_t * mirkl_error_aprwrapf_i | ( | apr_status_t | status, |
int | line, | ||
const char * | file, | ||
const char * | func, | ||
const char * | fmt, | ||
... | |||
) |
Wrap a status from an APR function. If fmt is NULL
, this is equivalent to mirkl_error_create(status,NULL,NULL). Otherwise, the error message is constructed by formatting fmt and the following arguments, and then appending ": " and the error message corresponding to status.
void mirkl_error_clear | ( | mirkl_error_t * | error | ) |
Free the memory used by error, as well as all ancestors and descendants of error.
Unlike other Subversion objects, errors are managed explicitly; you MUST clear an error if you are ignoring it, or you are leaking memory. For convenience, error may be NULL
, in which case this function does nothing; thus, #mirkl_error_clear(mirkl_foo(...)) works as an idiom to ignore errors.
void mirkl_error_compose | ( | mirkl_error_t * | chain, |
mirkl_error_t * | new_err | ||
) |
Add new_err to the end of chain's chain of errors. The new_err chain will be copied into chain's pool and destroyed, so new_err itself becomes invalid after this function.
mirkl_error_t * mirkl_error_compose_create | ( | mirkl_error_t * | err1, |
mirkl_error_t * | err2 | ||
) |
Compose two errors, returning err1. Either or both of err1 and err2 may be MIRKL_NO_ERROR
. If one of the errors is MIRKL_NO_ERROR
, the other is returned. If both are MIRKL_NO_ERROR
, MIRKL_NO_ERROR
is returned. If both are not MIRKL_NO_ERROR
, mirkl_error_compose is called, i.e. err2 will follow err1 in the chain of the returned error and err2 is invalid after this function.
mirkl_error_t * mirkl_error_create_i | ( | int | err_type, |
int | err_code, | ||
int | line, | ||
const char * | file, | ||
const char * | func, | ||
mirkl_error_t * | child, | ||
const char * | message | ||
) |
Create a nested exception structure.
Input: an APR or MirKL custom error code, a "child" error to wrap, a specific message
NULL
if there is nothing to add to the general message associated with the error code.If creating the "bottommost" error in a chain, pass NULL
for the child argument.
mirkl_error_t * mirkl_error_createf_i | ( | int | err_type, |
int | err_code, | ||
int | line, | ||
const char * | file, | ||
const char * | func, | ||
mirkl_error_t * | child, | ||
const char * | fmt, | ||
... | |||
) |
Create an error structure with the given err_type, err_code and child, with a printf-style error message produced by passing fmt and arguments.
void mirkl_error_deserialize | ( | mirkl_error_t ** | error, |
void * | buffer, | ||
mirkl_size_t | length | ||
) |
DeSerialize an error to buffer.
[in] | buffer | binary data, serialized error. |
[in] | length | length of the buffer. |
[out] | error | created from the serialized data. |
void mirkl_error_malfunction | ( | mirkl_error_t * | error | ) |
A helper function for the macros that report malfunctions.
Handle a malfunction by calling the current "malfunction handler" which may have been specified by a call to mirkl_error_set_malfunction_handler() or else is the default handler as specified in that function's documentation.
mirkl_error_t * mirkl_error_quick_wrap_i | ( | int | line, |
const char * | file, | ||
const char * | func, | ||
mirkl_error_t * | child, | ||
const char * | new_msg | ||
) |
A quick n' easy way to create a wrapped exception with your own message, before throwing it up the stack. (It uses all of the child's fields.)
mirkl_error_t * mirkl_error_root_cause | ( | mirkl_error_t * | err | ) |
Return the root cause of err by finding the last error in its chain (e.g. it or its children). err may be MIRKL_NO_ERROR
, in which case MIRKL_NO_ERROR
is returned.
void mirkl_error_serialize | ( | mirkl_error_t * | error, |
void ** | buffer, | ||
mirkl_size_t * | length | ||
) |
Serialize an error to buffer.
The length of the filled-in buffer is in length on output.
mirkl_error_malfunction_handler_t mirkl_error_set_malfunction_handler | ( | mirkl_error_malfunction_handler_t | func | ) |
Cause subsequent malfunctions to be handled by func.
Return the handler that was previously in effect. func may not be NULL
.
|
extern |
Special preallocated error, which causes functions mirkl_dl_mwalk_err_first() to stop walking through the lists if a callback function returns this error. The walking functions do not return this error.