Volksdata 1.0b10
RDF library
Loading...
Searching...
No Matches
Error handling
Collaboration diagram for Error handling:

Macros

#define CALLOC_GUARD(var, rc)
 Allocate one pointer with calloc and return rc if it fails.
#define CHECK(exp, marker)
 Jump to marker if exp does not return VOLK_OK.
#define log_debug(...)
#define LOG_RC(rc)
 Log an error or warning for return codes that are not VOLK_OK.
#define log_trace(...)
#define MALLOC_GUARD(var, rc)
 Allocate one pointer with malloc and return rc if it fails.
#define NLCHECK(exp, marker)
 Log error and jump to marker if exp is NULL.
#define NLNL(exp)
 Log error and return NULL if exp is NULL.
#define NLRCCK(exp, _rc)
 Return rc return code if exp is NULL.
#define PCHECK(exp, marker)
 Jump to marker if exp returns a negative value (skip warnings).
#define PRCCK(exp)
 Return exp return value if it is of VOLK_rc type and negative (=error).
#define PRCNL(exp)
 Return NULL if exp returns a negative value (=error).
#define RCCK(exp)
 Return exp return value if it is of VOLK_rc type and nonzero.
#define RCNL(exp)
 Return NULL if exp returns a nonzero value.
#define VOLK_MAX_ERROR   -88000
#define VOLK_MAX_WARNING   88899
#define VOLK_MIN_ERROR   VOLK_ERROR
 Minimum error value.
#define VOLK_MIN_WARNING   VOLK_NOACTION
 First warning value.

Detailed Description

Macro Definition Documentation

◆ CALLOC_GUARD

#define CALLOC_GUARD ( var,
rc )
Value:
do { \
(var) = calloc (1, sizeof *(var)); \
if (UNLIKELY (var == NULL)) return (rc); \
} while (0)
#define UNLIKELY(x)
Definition core.h:39

Allocate one pointer with calloc and return rc if it fails.

Definition at line 415 of file core.h.

◆ CHECK

#define CHECK ( exp,
marker )
Value:
do { \
VOLK_rc _rc = (exp); \
LOG_RC(_rc); \
if (UNLIKELY (_rc != VOLK_OK)) { \
log_error ( \
"*** PREMATURE EXIT due to error: %s", \
VOLK_strerror (_rc)); \
goto marker; \
} \
} while (0)
#define BREAKPOINT
Definition core.h:33
#define VOLK_OK
Generic success return code.
Definition core.h:95
int VOLK_rc
Return code.
Definition core.h:91
const char * VOLK_strerror(VOLK_rc rc)
Return an error message for a return code.
Definition core.c:196

Jump to marker if exp does not return VOLK_OK.

Definition at line 311 of file core.h.

◆ log_debug

#define log_debug ( ...)
Value:
do {} while(0)

Definition at line 294 of file core.h.

◆ LOG_RC

#define LOG_RC ( rc)
Value:
do { \
if ((rc) < 0) log_error (VOLK_strerror (rc)); \
else if ((rc) > 0) log_warn (VOLK_strerror (rc)); \
} while (0)

Log an error or warning for return codes that are not VOLK_OK.

Note that, if used outside of the other macros below, care must be taken to pass it an actual return code rather than an expression, otherwise the expression will be evaluated multiple times.

Definition at line 305 of file core.h.

◆ log_trace

#define log_trace ( ...)
Value:
do {} while(0)

Definition at line 296 of file core.h.

◆ MALLOC_GUARD

#define MALLOC_GUARD ( var,
rc )
Value:
do { \
(var) = malloc (sizeof *(var)); \
if (UNLIKELY (var == NULL)) return (rc); \
} while (0)

Allocate one pointer with malloc and return rc if it fails.

Definition at line 409 of file core.h.

◆ NLCHECK

#define NLCHECK ( exp,
marker )
Value:
do { \
if (UNLIKELY ((exp) == NULL)) { \
log_error ("*** PREMATURE EXIT due to NULL result."); \
goto marker; \
} \
} while (0);

Log error and jump to marker if exp is NULL.

Definition at line 337 of file core.h.

◆ NLNL

#define NLNL ( exp)
Value:
do { \
if (UNLIKELY ((exp) == NULL)) { \
log_error ("*** PREMATURE EXIT due to NULL result."); \
return NULL; \
} \
} while (0)

Log error and return NULL if exp is NULL.

Definition at line 401 of file core.h.

◆ NLRCCK

#define NLRCCK ( exp,
_rc )
Value:
do { \
if (UNLIKELY ((exp) == NULL)) { \
log_error ("*** PREMATURE EXIT due to NULL result."); \
return _rc; \
} \
} while (0)

Return rc return code if exp is NULL.

Definition at line 370 of file core.h.

◆ PCHECK

#define PCHECK ( exp,
marker )
Value:
do { \
VOLK_rc _rc = (exp); \
if (UNLIKELY (_rc < VOLK_OK)) { \
log_error ( \
"*** PREMATURE EXIT due to error: %s", \
VOLK_strerror (_rc)); \
LOG_RC(_rc); \
goto marker; \
} \
} while (0)

Jump to marker if exp returns a negative value (skip warnings).

Definition at line 324 of file core.h.

◆ PRCCK

#define PRCCK ( exp)
Value:
do { \
VOLK_rc _rc = (exp); \
if (UNLIKELY (_rc < VOLK_OK)) { \
log_error ( \
"*** PREMATURE EXIT due to error: %s (%d)", \
VOLK_strerror (_rc), _rc); \
return _rc; \
} \
} while (0)

Return exp return value if it is of VOLK_rc type and negative (=error).

Definition at line 358 of file core.h.

◆ PRCNL

#define PRCNL ( exp)
Value:
do { \
VOLK_rc _rc = (exp); \
if (UNLIKELY (_rc < VOLK_OK)) { \
log_error ( \
"*** PREMATURE EXIT due to error: %s (%d)", \
VOLK_strerror (_rc), _rc); \
return NULL; \
} \
} while (0)

Return NULL if exp returns a negative value (=error).

Definition at line 390 of file core.h.

◆ RCCK

#define RCCK ( exp)
Value:
do { \
VOLK_rc _rc = (exp); \
if (UNLIKELY (_rc != VOLK_OK)) { \
log_error ( \
"*** PREMATURE EXIT due to non-zero exit: %s (%d)", \
VOLK_strerror (_rc), _rc); \
return _rc; \
} \
} while (0)

Return exp return value if it is of VOLK_rc type and nonzero.

Definition at line 346 of file core.h.

◆ RCNL

#define RCNL ( exp)
Value:
do { \
VOLK_rc _rc = (exp); \
if (UNLIKELY (_rc != VOLK_OK)) { \
log_error ( \
"*** PREMATURE EXIT due to non-zero exit: %s (%d)", \
VOLK_strerror (_rc), _rc); \
return NULL; \
} \
} while (0);

Return NULL if exp returns a nonzero value.

Definition at line 379 of file core.h.

◆ VOLK_MAX_ERROR

#define VOLK_MAX_ERROR   -88000

brief Maximum error value.

Note
When adding new error codes, use a value smaller than this.

Definition at line 275 of file core.h.

◆ VOLK_MAX_WARNING

#define VOLK_MAX_WARNING   88899

brief Maximum warning value.

Note
When adding new warning codes, use a value smaller than this.

Definition at line 284 of file core.h.

◆ VOLK_MIN_ERROR

#define VOLK_MIN_ERROR   VOLK_ERROR

Minimum error value.

Definition at line 270 of file core.h.

◆ VOLK_MIN_WARNING

#define VOLK_MIN_WARNING   VOLK_NOACTION

First warning value.

Definition at line 278 of file core.h.