Libtrap: Internal development docs  1.16.1
Functions | Variables
trap_error.h File Reference

Error handling for TRAP. More...

#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "trap_internal.h"
#include "../include/libtrap/trap.h"
Include dependency graph for trap_error.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static int trap_error (trap_ctx_priv_t *ctx, int err_num)
 
static int trap_errorf (trap_ctx_priv_t *ctx, int err_num, const char *msg,...)
 
static int trap_errorp (trap_ctx_priv_t *ctx, const char *msg,...)
 

Variables

const char * default_err_msg [256]
 

Detailed Description

Error handling for TRAP.

Author
Vaclav Bartos ibart.nosp@m.osv@.nosp@m.fit.v.nosp@m.utbr.nosp@m..cz
Tomas Cejka cejka.nosp@m.to2@.nosp@m.fit.c.nosp@m.vut..nosp@m.cz
Tomas Jansky jansk.nosp@m.to1@.nosp@m.fit.c.nosp@m.vut..nosp@m.cz
Date
2013 - 2018

Definition in file trap_error.h.

Function Documentation

◆ trap_error()

static int trap_error ( trap_ctx_priv_t ctx,
int  err_num 
)
inlinestatic

Set error with default message.

Parameters
[in]ctxlibtrap context
[in]err_numError 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]ctxlibtrap context
[in]err_numError number as defined in trap.h
[in]msgHuman-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()

static int trap_errorp ( trap_ctx_priv_t ctx,
const char *  msg,
  ... 
)
inlinestatic

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]ctxlibtrap context
[in]msgString 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.

Variable Documentation

◆ 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.