IUF-SDK-3
Interventional Ultrasound Library
iufError.c File Reference
#include <stdarg.h>
#include <memory.h>
#include <string.h>
#include "iuf.h"
#include "library_config.h"

Data Structures

struct  IufError
 

Macros

#define ERR_CLS_NAME   "IUF"
 
#define IUF_ERR_MAJ_HDF5_MSG   "HDF5 call failed"
 
#define IUF_ERR_MAJ_GENERAL_MSG   "General Error"
 
#define IUF_ERR_MAJ_MEMORY_MSG   "Memory Error"
 
#define IUF_ERR_MAJ_VALUE_MSG   "Value Error"
 
#define IUF_ERR_MAJ_ERROR_MSG   "Error handling"
 
#define IUF_NAME   "IUF-SDK"
 
#define IUF_VERSION   IUF_VERSION_MAJOR "." IUF_VERSION_MINOR "." IUF_VERSION_PATCH
 
#define IUF_ERR_MIN_ARG_VALUE_MSG   "Value invalid for argument"
 
#define IUF_ERR_MIN_ARG_NULL_VALUE_MSG   "NULL value invalid for argument"
 
#define IUF_ERR_MIN_ARG_FILENAME_MSG   "Invalid filename argument"
 
#define IUF_ERR_MIN_ALLOC_MSG   "Memory allocation failed"
 
#define IUF_ERR_MIN_MEMCOPY_MSG   "Memory copy failed"
 
#define IUF_ERR_MIN_FORMAT_MSG   "Error message formatting failed"
 
#define IUF_ERR_MIN_ARG_DUPLICATE_KEY_MSG   "Duplicate key"
 
#define IUF_ERR_MIN_ARG_INVALID_KEY_MSG   "Invalid key, lookup failed"
 
#define IUF_ERR_MIN_HDF5_MSG   "Turn on HDF5 error log to get error details: iufHDF5ErrorLog(IUF_TRUE)"
 
#define IUF_ERR_MIN_ASSERT_FAILED_MSG   "Assertion failed"
 
#define IUE_INVALID   (iue_t) NULL
 

Typedefs

typedef IufErroriue_t
 

Functions

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 iufErrorGetCount (void)
 Get the number of errors that occurred so far. More...
 
int build_error_string (unsigned int n, const struct H5E_error2_t *err_desc, void *cb_data)
 
int iufErrorPrint ()
 Prints the Error stack. More...
 
int iufErrorLogClear (void)
 Removes all messages from the error stack. More...
 
char * iufErrorString ()
 Create a string representation of the current Error stack. More...
 
int iufErrorLog (IUF_BOOL enable)
 Enable or disable IUF library error logging. More...
 
int iufHDF5ErrorLog (IUF_BOOL enable)
 Enable or disable HDF5 library error logging. More...
 
IUF_BOOL iufErrorAutoReportGet (void)
 Error messages wil printed when encountered by the library calls. More...
 
int iufErrorAutoReportSet (IUF_BOOL enable)
 Error messages wil printed when encountered by the library calls. 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...
 

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_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_ARG_VALUE
 Minor error handling class for argument value errors. More...
 
hid_t IUF_ERR_MIN_ASSERT_FAILED
 Minor error handling class for assertion errors. More...
 

Data Structure Documentation

◆ IufError

struct IufError
Data Fields
IUF_BOOL autoReport
void * client_data
IUF_BOOL enable
char error_buffer[IUF_MAX_STRING_LENGTH]
FILE * errorStream
H5E_auto2_t func
hid_t iufErrorClass
hid_t iufErrorStack

Macro Definition Documentation

◆ ERR_CLS_NAME

#define ERR_CLS_NAME   "IUF"

◆ IUE_INVALID

#define IUE_INVALID   (iue_t) NULL

◆ IUF_ERR_MAJ_ERROR_MSG

#define IUF_ERR_MAJ_ERROR_MSG   "Error handling"

◆ IUF_ERR_MAJ_GENERAL_MSG

#define IUF_ERR_MAJ_GENERAL_MSG   "General Error"

◆ IUF_ERR_MAJ_HDF5_MSG

#define IUF_ERR_MAJ_HDF5_MSG   "HDF5 call failed"

◆ IUF_ERR_MAJ_MEMORY_MSG

#define IUF_ERR_MAJ_MEMORY_MSG   "Memory Error"

◆ IUF_ERR_MAJ_VALUE_MSG

#define IUF_ERR_MAJ_VALUE_MSG   "Value Error"

◆ IUF_ERR_MIN_ALLOC_MSG

#define IUF_ERR_MIN_ALLOC_MSG   "Memory allocation failed"

◆ IUF_ERR_MIN_ARG_DUPLICATE_KEY_MSG

#define IUF_ERR_MIN_ARG_DUPLICATE_KEY_MSG   "Duplicate key"

◆ IUF_ERR_MIN_ARG_FILENAME_MSG

#define IUF_ERR_MIN_ARG_FILENAME_MSG   "Invalid filename argument"

◆ IUF_ERR_MIN_ARG_INVALID_KEY_MSG

#define IUF_ERR_MIN_ARG_INVALID_KEY_MSG   "Invalid key, lookup failed"

◆ IUF_ERR_MIN_ARG_NULL_VALUE_MSG

#define IUF_ERR_MIN_ARG_NULL_VALUE_MSG   "NULL value invalid for argument"

◆ IUF_ERR_MIN_ARG_VALUE_MSG

#define IUF_ERR_MIN_ARG_VALUE_MSG   "Value invalid for argument"

◆ IUF_ERR_MIN_ASSERT_FAILED_MSG

#define IUF_ERR_MIN_ASSERT_FAILED_MSG   "Assertion failed"

◆ IUF_ERR_MIN_FORMAT_MSG

#define IUF_ERR_MIN_FORMAT_MSG   "Error message formatting failed"

◆ IUF_ERR_MIN_HDF5_MSG

#define IUF_ERR_MIN_HDF5_MSG   "Turn on HDF5 error log to get error details: iufHDF5ErrorLog(IUF_TRUE)"

◆ IUF_ERR_MIN_MEMCOPY_MSG

#define IUF_ERR_MIN_MEMCOPY_MSG   "Memory copy failed"

◆ IUF_NAME

#define IUF_NAME   "IUF-SDK"

◆ IUF_VERSION

#define IUF_VERSION   IUF_VERSION_MAJOR "." IUF_VERSION_MINOR "." IUF_VERSION_PATCH

Typedef Documentation

◆ iue_t

typedef IufError* iue_t

Function Documentation

◆ build_error_string()

int build_error_string ( unsigned int  n,
const struct H5E_error2_t *  err_desc,
void *  cb_data 
)

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