IUF-SDK-3
Interventional Ultrasound Library
iufError.h File Reference

IUF error codes. More...

#include <iuf.h>
#include <stdio.h>
#include <stdlib.h>

Go to the source code of this file.

Macros

#define IUF_ERROR_PUSH(maj, min, msg)   iufErrorPush(__FILE__, __func__, __LINE__, maj, min, msg)
 Convenience macro, that pushes the error from current file function and line number. More...
 
#define IUF_ERROR_PRINT(maj, min, msg)
 Convenience macro, that pushes the error from current file function and line number and prints it. More...
 
#define IUF_ERROR_FMT_PUSH(maj, min, fmt, ...)   iufErrorFormatAndPush(__FILE__, __func__, __LINE__, maj, min, fmt, __VA_ARGS__)
 Convenience macro, that formats and pushes the error from current file function and line number. More...
 
#define IUF_ERROR_FMT_PRINT(maj, min, fmt, ...)
 Convenience macro, that formats, pushes the error from current file function and line number and prints it. More...
 
#define IUF_ERR_ALLOC_NULL_N_RETURN(var, adt, retval)
 Convenience macro, that pushes IUF_ERR_MAJ_MEMORY, IUF_ERR_MIN_ALLOC for var that is NULL and returns retval. More...
 
#define IUF_ERR_CHECK_NULL_N_RETURN(var, retval)
 Convenience macro, that pushes IUF_ERR_MAJ_VALUE, IUF_ERR_MIN_ARG_NULL_VALUE for var that is NULL and returns retval. More...
 
#define IUF_ERR_CHECK_EMPTYSTR_N_RETURN(var, return_value)
 Convenience macro, that pushes IUF_ERR_MAJ_VALUE, IUF_ERR_MIN_ARG_VALUE for empty string var and returns retval. More...
 
#define IUF_ERR_STRP_NULL_EMPTY(var, retval)
 Convenience macro, that sequentially calls IUF_ERR_CHECK_NULL_N_RETURN and IUF_ERR_CHECK_EMPTYSTR_N_RETURN. More...
 
#define IUF_ERR_EVAL_N_RETURN(expr, retval)
 Convenience macro, that evaluates expression expr and pushes IUF_ERR_MAJ_VALUE, IUF_ERR_MIN_ARG_VALUE when true and returns retval. More...
 
#define IUF_ERR_GENERAL   (100001)
 List of error codes. More...
 
#define IUF_ERR_MEMORY   (100002)
 
#define IUF_ERR_VALUE   (100003)
 
#define IUF_UNUSED(x)   (void)(x)
 Prevent unused parameter warning. More...
 
#define IUF_ASSERT(IN_CONDITION)
 IUF assertion, general. More...
 
#define IUF_ASSERT_MEMORY(IN_CONDITION)
 IUF assertion, memory. More...
 
#define IUF_ASSERT_VALUE(IN_CONDITION)
 IUF assertion, value. More...
 

Functions

int iufErrorGetCount (void)
 Get the number of errors that occurred so far. More...
 
int iufErrorPrint ()
 Prints the Error stack. More...
 
char * iufErrorString ()
 Create a string representation of the current Error stack. More...
 
int iufErrorPush (const char *pFileName, const char *pFunctionName, int lineNumber, hid_t maj, hid_t min, char *msg)
 Pushes an Error context onto the IUF error stack. More...
 
int iufErrorFormatAndPush (const char *pFileName, const char *pFunctionName, int lineNumber, hid_t maj, hid_t min, char *msgFormat,...)
 Format and Push an Error context onto the IUF error stack. More...
 
int iufHDF5ErrorLog (IUF_BOOL enable)
 Enable or disable HDF5 library error logging. More...
 
int iufErrorLog (IUF_BOOL enable)
 Enable or disable IUF library error logging. More...
 
int iufErrorLogClear (void)
 Removes all messages from the error stack. More...
 
int iufErrorSetStream (FILE *stream)
 Error messages wil be printed to this FILE stream (i.e. stdout would sent the errors to console output). More...
 
int iufErrorSetStreamToFile (const char *pFileName)
 Error messages wil be printed to the file with name pFileName. More...
 
int iufErrorCloseFileStream ()
 Closes the filestream opened with iufErrorSetStreamToFile() and resets the stream to stderr. More...
 
int iufErrorAutoReportSet (IUF_BOOL enable)
 Error messages wil printed when encountered by the library calls. More...
 
IUF_BOOL iufErrorAutoReportGet (void)
 Error messages wil printed when encountered by the library calls. More...
 

Variables

hid_t IUF_ERR_MAJ_GENERAL
 Major error handling class for general errors. More...
 
hid_t IUF_ERR_MAJ_MEMORY
 Major error handling class for memory errors. More...
 
hid_t IUF_ERR_MAJ_VALUE
 Major error handling class for value related errors. More...
 
hid_t IUF_ERR_MAJ_ERROR
 Major error handling class for errors. More...
 
hid_t IUF_ERR_MAJ_HDF5
 Major error handling class for hdf5 io errors. More...
 
hid_t IUF_ERR_MIN_ARG_VALUE
 Minor error handling class for argument value errors. More...
 
hid_t IUF_ERR_MIN_ARG_FILENAME
 Minor error handling class for filename errors. More...
 
hid_t IUF_ERR_MIN_ALLOC
 Minor error handling class for memory allocation value errors. More...
 
hid_t IUF_ERR_MIN_MEMCOPY
 Minor error handling class for memory errors. More...
 
hid_t IUF_ERR_MIN_FORMAT
 Minor error handling class for formatting errors. More...
 
hid_t IUF_ERR_MIN_ARG_NULL_VALUE
 Minor error handling class for NULL values. More...
 
hid_t IUF_ERR_MIN_ARG_DUPLICATE_KEY
 Minor error handling class for duplicate key errors in a dictionary. More...
 
hid_t IUF_ERR_MIN_ARG_INVALID_KEY
 Minor error handling class for invalid key errors in a dictionary. More...
 
hid_t IUF_ERR_MIN_HDF5
 Minor error handling class for invalid hdf5 file io errors. More...
 
hid_t IUF_ERR_MIN_ASSERT_FAILED
 Minor error handling class for assertion errors. More...
 

Detailed Description

IUF error codes.

Author
Harm Belt

Macro Definition Documentation

◆ IUF_ASSERT

#define IUF_ASSERT (   IN_CONDITION)
Value:
{ \
if ( !(IN_CONDITION) )\
{ \
IUF_ERROR_PUSH(IUF_ERR_MAJ_GENERAL,IUF_ERR_MIN_ASSERT_FAILED, "General error occurred, assertion failed for " #IN_CONDITION); \
exit( IUF_ERR_GENERAL ); \
} \
}
hid_t IUF_ERR_MAJ_GENERAL
Major error handling class for general errors.
Definition: iufError.c:9
hid_t IUF_ERR_MIN_ASSERT_FAILED
Minor error handling class for assertion errors.
Definition: iufError.c:25
#define IUF_ERR_GENERAL
List of error codes.
Definition: iufError.h:228

IUF assertion, general.

◆ IUF_ASSERT_MEMORY

#define IUF_ASSERT_MEMORY (   IN_CONDITION)
Value:
{ \
if ( !(IN_CONDITION) )\
{ \
IUF_ERROR_PUSH(IUF_ERR_MAJ_MEMORY,IUF_ERR_MIN_ASSERT_FAILED, "Memory error occurred, assertion failed for " #IN_CONDITION); \
exit( IUF_ERR_MEMORY ); \
} \
}
#define IUF_ERR_MEMORY
Definition: iufError.h:229
hid_t IUF_ERR_MIN_ASSERT_FAILED
Minor error handling class for assertion errors.
Definition: iufError.c:25
hid_t IUF_ERR_MAJ_MEMORY
Major error handling class for memory errors.
Definition: iufError.c:10

IUF assertion, memory.

◆ IUF_ASSERT_VALUE

#define IUF_ASSERT_VALUE (   IN_CONDITION)
Value:
{ \
if ( !(IN_CONDITION) )\
{ \
IUF_ERROR_PUSH(IUF_ERR_MAJ_VALUE,IUF_ERR_MIN_ASSERT_FAILED, "Value error occurred, assertion failed for " #IN_CONDITION); \
exit( IUF_ERR_VALUE ); \
} \
}
#define IUF_ERR_VALUE
Definition: iufError.h:230
hid_t IUF_ERR_MIN_ASSERT_FAILED
Minor error handling class for assertion errors.
Definition: iufError.c:25
hid_t IUF_ERR_MAJ_VALUE
Major error handling class for value related errors.
Definition: iufError.c:11

IUF assertion, value.

◆ IUF_ERR_ALLOC_NULL_N_RETURN

#define IUF_ERR_ALLOC_NULL_N_RETURN (   var,
  adt,
  retval 
)
Value:
if ((var) == NULL) { \
IUF_ERROR_PUSH(IUF_ERR_MAJ_MEMORY, IUF_ERR_MIN_ALLOC, "calloc failed for " #adt); \
return retval; \
}
hid_t IUF_ERR_MIN_ALLOC
Minor error handling class for memory allocation value errors.
Definition: iufError.c:16
hid_t IUF_ERR_MAJ_MEMORY
Major error handling class for memory errors.
Definition: iufError.c:10

Convenience macro, that pushes IUF_ERR_MAJ_MEMORY, IUF_ERR_MIN_ALLOC for var that is NULL and returns retval.

Returns
Returns retval.

◆ IUF_ERR_CHECK_EMPTYSTR_N_RETURN

#define IUF_ERR_CHECK_EMPTYSTR_N_RETURN (   var,
  return_value 
)
Value:
if (strcmp((var),"") == 0) { \
IUF_ERROR_PUSH(IUF_ERR_MAJ_VALUE, IUF_ERR_MIN_ARG_VALUE, "argument " #var " was empty"); \
return return_value; \
}
hid_t IUF_ERR_MAJ_VALUE
Major error handling class for value related errors.
Definition: iufError.c:11
hid_t IUF_ERR_MIN_ARG_VALUE
Minor error handling class for argument value errors.
Definition: iufError.c:24

Convenience macro, that pushes IUF_ERR_MAJ_VALUE, IUF_ERR_MIN_ARG_VALUE for empty string var and returns retval.

Returns
Returns retval.

◆ IUF_ERR_CHECK_NULL_N_RETURN

#define IUF_ERR_CHECK_NULL_N_RETURN (   var,
  retval 
)
Value:
if ((var) == NULL) { \
IUF_ERROR_PUSH(IUF_ERR_MAJ_VALUE, IUF_ERR_MIN_ARG_NULL_VALUE, "argument " #var " was NULL"); \
return retval; \
}
hid_t IUF_ERR_MIN_ARG_NULL_VALUE
Minor error handling class for NULL values.
Definition: iufError.c:20
hid_t IUF_ERR_MAJ_VALUE
Major error handling class for value related errors.
Definition: iufError.c:11

Convenience macro, that pushes IUF_ERR_MAJ_VALUE, IUF_ERR_MIN_ARG_NULL_VALUE for var that is NULL and returns retval.

Returns
Returns retval.

◆ IUF_ERR_EVAL_N_RETURN

#define IUF_ERR_EVAL_N_RETURN (   expr,
  retval 
)
Value:
if (expr) { \
IUF_ERROR_PUSH(IUF_ERR_MAJ_VALUE, IUF_ERR_MIN_ARG_VALUE, #expr ""); \
return retval; \
}
hid_t IUF_ERR_MAJ_VALUE
Major error handling class for value related errors.
Definition: iufError.c:11
hid_t IUF_ERR_MIN_ARG_VALUE
Minor error handling class for argument value errors.
Definition: iufError.c:24

Convenience macro, that evaluates expression expr and pushes IUF_ERR_MAJ_VALUE, IUF_ERR_MIN_ARG_VALUE when true and returns retval.

Returns
Returns retval.

◆ IUF_ERR_GENERAL

#define IUF_ERR_GENERAL   (100001)

List of error codes.

general error

◆ IUF_ERR_MEMORY

#define IUF_ERR_MEMORY   (100002)

memory error

◆ IUF_ERR_STRP_NULL_EMPTY

#define IUF_ERR_STRP_NULL_EMPTY (   var,
  retval 
)
Value:
IUF_ERR_CHECK_EMPTYSTR_N_RETURN(var, retval)
#define IUF_ERR_CHECK_NULL_N_RETURN(var, retval)
Convenience macro, that pushes IUF_ERR_MAJ_VALUE, IUF_ERR_MIN_ARG_NULL_VALUE for var that is NULL and...
Definition: iufError.h:195

Convenience macro, that sequentially calls IUF_ERR_CHECK_NULL_N_RETURN and IUF_ERR_CHECK_EMPTYSTR_N_RETURN.

Returns
Returns retval.

◆ IUF_ERR_VALUE

#define IUF_ERR_VALUE   (100003)

value error

◆ IUF_ERROR_FMT_PRINT

#define IUF_ERROR_FMT_PRINT (   maj,
  min,
  fmt,
  ... 
)
Value:
iufErrorFormatAndPush(__FILE__, __func__, __LINE__, maj, min, fmt, __VA_ARGS__);\
iufErrorPrint();
int iufErrorFormatAndPush(const char *pFileName, const char *pFunctionName, int lineNumber, hid_t maj, hid_t min, char *msgFormat,...)
Format and Push an Error context onto the IUF error stack.
Definition: iufError.c:161

Convenience macro, that formats, pushes the error from current file function and line number and prints it.

◆ IUF_ERROR_FMT_PUSH

#define IUF_ERROR_FMT_PUSH (   maj,
  min,
  fmt,
  ... 
)    iufErrorFormatAndPush(__FILE__, __func__, __LINE__, maj, min, fmt, __VA_ARGS__)

Convenience macro, that formats and pushes the error from current file function and line number.

◆ IUF_ERROR_PRINT

#define IUF_ERROR_PRINT (   maj,
  min,
  msg 
)
Value:
iufErrorPush(__FILE__, __func__, __LINE__, maj, min, msg);\
iufErrorPrint();
int iufErrorPush(const char *pFileName, const char *pFunctionName, int lineNumber, hid_t maj, hid_t min, char *msg)
Pushes an Error context onto the IUF error stack.
Definition: iufError.c:142

Convenience macro, that pushes the error from current file function and line number and prints it.

◆ IUF_ERROR_PUSH

#define IUF_ERROR_PUSH (   maj,
  min,
  msg 
)    iufErrorPush(__FILE__, __func__, __LINE__, maj, min, msg)

Convenience macro, that pushes the error from current file function and line number.

◆ IUF_UNUSED

#define IUF_UNUSED (   x)    (void)(x)

Prevent unused parameter warning.

Function Documentation

◆ iufErrorAutoReportGet()

IUF_BOOL iufErrorAutoReportGet ( void  )

Error messages wil printed when encountered by the library calls.

Returns
Returns the value IUF_TRUE when auto reporting is enabled, IUF_FALSE when disabled.

◆ iufErrorAutoReportSet()

int iufErrorAutoReportSet ( IUF_BOOL  enable)

Error messages wil printed when encountered by the library calls.

Returns
Returns IUF_E_OK when successful or IUF_ERR_VALUE in case of an error.
Parameters
enableIUF_TRUE enables / IUF_FALSE disables automatic error logging

◆ iufErrorCloseFileStream()

int iufErrorCloseFileStream ( )

Closes the filestream opened with iufErrorSetStreamToFile() and resets the stream to stderr.

Returns
Returns IUF_E_OK when successful or IUF_ERR_VALUE in case of an error.

◆ iufErrorFormatAndPush()

int iufErrorFormatAndPush ( const char *  pFileName,
const char *  pFunctionName,
int  lineNumber,
hid_t  maj,
hid_t  min,
char *  msgFormat,
  ... 
)

Format and Push an Error context onto the IUF error stack.

Returns
Returns IUF_E_OK when successful or IUF_ERR_VALUE in case of an error.
Parameters
pFileNameThe source file of the error
pFunctionNameThe function that caused the error
lineNumberThe line number in the source file of the error
majThe major error class
minThe minor error class
msgFormatThe error message format (like sprintf)

◆ iufErrorGetCount()

int iufErrorGetCount ( void  )

Get the number of errors that occurred so far.

Returns
Returns the number of errors that occurred so far

◆ iufErrorLog()

int iufErrorLog ( IUF_BOOL  enable)

Enable or disable IUF library error logging.

Returns
Returns IUF_E_OK when successful or IUF_ERR_VALUE in case of an error.
Parameters
enableIUF_TRUE enables / IUF_FALSE disables error logging

◆ iufErrorLogClear()

int iufErrorLogClear ( void  )

Removes all messages from the error stack.

Returns
Returns IUF_E_OK when successful or IUF_ERR_VALUE in case of an error.

◆ iufErrorPrint()

int iufErrorPrint ( )

Prints the Error stack.

Returns
Returns IUF_E_OK when successful or IUF_ERR_VALUE in case of an error.

◆ iufErrorPush()

int iufErrorPush ( const char *  pFileName,
const char *  pFunctionName,
int  lineNumber,
hid_t  maj,
hid_t  min,
char *  msg 
)

Pushes an Error context onto the IUF error stack.

Returns
Returns IUF_E_OK when successful or IUF_ERR_VALUE in case of an error.
Parameters
pFileNameThe source file of the error
pFunctionNameThe function that caused the error
lineNumberThe line number in the source file of the error
majThe major error class
minThe minor error class
msgThe error message

◆ iufErrorSetStream()

int iufErrorSetStream ( FILE *  stream)

Error messages wil be printed to this FILE stream (i.e. stdout would sent the errors to console output).

Returns
Returns IUF_E_OK when successful or IUF_ERR_VALUE in case of an error.
Parameters
streamValid FILE stream like from fopen or constants like stderr/stdout

◆ iufErrorSetStreamToFile()

int iufErrorSetStreamToFile ( const char *  pFileName)

Error messages wil be printed to the file with name pFileName.

Returns
Returns IUF_E_OK when successful or IUF_ERR_VALUE in case of an error.

◆ iufErrorString()

char* iufErrorString ( )

Create a string representation of the current Error stack.

Returns
Returns a string representation of the current Error stack.

◆ iufHDF5ErrorLog()

int iufHDF5ErrorLog ( IUF_BOOL  enable)

Enable or disable HDF5 library error logging.

Returns
Returns IUF_E_OK when successful or IUF_ERR_VALUE in case of an error.
Parameters
enableIUF_TRUE enables / IUF_FALSE disables error logging

Variable Documentation

◆ IUF_ERR_MAJ_ERROR

hid_t IUF_ERR_MAJ_ERROR

Major error handling class for errors.

◆ IUF_ERR_MAJ_GENERAL

hid_t IUF_ERR_MAJ_GENERAL

Major error handling class for general errors.

◆ IUF_ERR_MAJ_HDF5

hid_t IUF_ERR_MAJ_HDF5

Major error handling class for hdf5 io errors.

◆ IUF_ERR_MAJ_MEMORY

hid_t IUF_ERR_MAJ_MEMORY

Major error handling class for memory errors.

◆ IUF_ERR_MAJ_VALUE

hid_t IUF_ERR_MAJ_VALUE

Major error handling class for value related errors.

◆ IUF_ERR_MIN_ALLOC

hid_t IUF_ERR_MIN_ALLOC

Minor error handling class for memory allocation value errors.

◆ IUF_ERR_MIN_ARG_DUPLICATE_KEY

hid_t IUF_ERR_MIN_ARG_DUPLICATE_KEY

Minor error handling class for duplicate key errors in a dictionary.

◆ IUF_ERR_MIN_ARG_FILENAME

hid_t IUF_ERR_MIN_ARG_FILENAME

Minor error handling class for filename errors.

◆ IUF_ERR_MIN_ARG_INVALID_KEY

hid_t IUF_ERR_MIN_ARG_INVALID_KEY

Minor error handling class for invalid key errors in a dictionary.

◆ IUF_ERR_MIN_ARG_NULL_VALUE

hid_t IUF_ERR_MIN_ARG_NULL_VALUE

Minor error handling class for NULL values.

◆ IUF_ERR_MIN_ARG_VALUE

hid_t IUF_ERR_MIN_ARG_VALUE

Minor error handling class for argument value errors.

◆ IUF_ERR_MIN_ASSERT_FAILED

hid_t IUF_ERR_MIN_ASSERT_FAILED

Minor error handling class for assertion errors.

◆ IUF_ERR_MIN_FORMAT

hid_t IUF_ERR_MIN_FORMAT

Minor error handling class for formatting errors.

◆ IUF_ERR_MIN_HDF5

hid_t IUF_ERR_MIN_HDF5

Minor error handling class for invalid hdf5 file io errors.

◆ IUF_ERR_MIN_MEMCOPY

hid_t IUF_ERR_MIN_MEMCOPY

Minor error handling class for memory errors.