Error handling for TRAP.
More...
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "trap_internal.h"
#include "../include/libtrap/trap.h"
Go to the source code of this file.
◆ trap_error()
Set error with default message.
- Parameters
-
[in] | ctx | libtrap context |
[in] | err_num | Error number as defined in trap.h |
- Returns
- err_num
Definition at line 63 of file trap_error.h.
◆ trap_errorf()
static int trap_errorf |
( |
trap_ctx_priv_t * |
ctx, |
|
|
int |
err_num, |
|
|
const char * |
msg, |
|
|
|
... |
|
) |
| |
|
inlinestatic |
Set error with custom message (printf-like formatting).
- Parameters
-
[in] | ctx | libtrap context |
[in] | err_num | Error number as defined in trap.h |
[in] | msg | Human-readable string describing error, supports printf formatting. |
[in] | ... | Additional parameters for printf-like formatting of msg. |
- Returns
- err_num
Definition at line 92 of file trap_error.h.
◆ trap_errorp()
Prepend given string before current ctx->trap_last_error_msg. This function is useful when a call of some function fails and you want to print a message about it but keep the original message about the error inside the function. Expected usage: return errorp("Call of myFunc failed: ");
- Parameters
-
[in] | ctx | libtrap context |
[in] | msg | String to prepend current message |
[in] | ... | Additional parameters for printf-like formatting of msg. |
- Returns
- Current value of ctx->trap_last_error
Definition at line 120 of file trap_error.h.
◆ default_err_msg
const char* default_err_msg[256] |
Default error message for each error code
Definition at line 49 of file trap_error.c.