PDI 1.7.0-alpha.2023-10-26

the PDI data interface

Error handling

The error handling API supports checking the error status of PDI. More...

Classes

struct  PDI_errhandler_t
 Definition of an error handler. More...
 

Typedefs

typedef void(* PDI_errfunc_f) (PDI_status_t status, const char *message, void *context)
 Type of a callback function used when an error occurs.
 

Enumerations

enum  PDI_status_t {
  PDI_OK = 0 ,
  PDI_UNAVAILABLE ,
  PDI_ERR_CONFIG ,
  PDI_ERR_VALUE ,
  PDI_ERR_PLUGIN ,
  PDI_ERR_IMPL ,
  PDI_ERR_SYSTEM ,
  PDI_ERR_STATE ,
  PDI_ERR_RIGHT ,
  PDI_ERR_TYPE
}
 Error codes of PDI. More...
 

Functions

const char * PDI_errmsg (void)
 Return a human-readabe message describing the last error that occured in PDI.
 
PDI_errhandler_t PDI_errhandler (PDI_errhandler_t handler)
 Sets the error handler to use.
 

Variables

const PDI_errhandler_t PDI_ASSERT_HANDLER
 Prints the error message and aborts if the status is invalid.
 
const PDI_errhandler_t PDI_WARN_HANDLER
 Prints the error message and continue if the status is invalid.
 
const PDI_errhandler_t PDI_NULL_HANDLER
 Does nothing.
 

Detailed Description

The error handling API supports checking the error status of PDI.

By default, errors in PDI C API are signaled by a return code of type PDI_status_t and an error message can be retrieved with the PDI_errmsg function. This default behavior can be changed by replacing the error handler with the PDI_errhandler function.


Class Documentation

◆ PDI_errhandler_t

struct PDI_errhandler_t

Definition of an error handler.

Class Members
PDI_errfunc_f func The function to handle the error (none if NULL)
void * context the context that will be provided to the function

Typedef Documentation

◆ PDI_errfunc_f

typedef void(* PDI_errfunc_f) (PDI_status_t status, const char *message, void *context)

Type of a callback function used when an error occurs.

Parameters
statusthe error code
messagethe human-readable error message
contexta user-provided context

Enumeration Type Documentation

◆ PDI_status_t

Error codes of PDI.

Enumerator
PDI_OK 

everything went well

PDI_UNAVAILABLE 

on an input call, no such data is available

PDI_ERR_CONFIG 

The configuration file is invalid.

PDI_ERR_VALUE 

A value expression is invalid.

PDI_ERR_PLUGIN 

Tried to load a non-existing plugin.

PDI_ERR_IMPL 

Implementation limitation (typically an unimplemented feature)

PDI_ERR_SYSTEM 

A system error occured (OS, etc.)

PDI_ERR_STATE 

A call to a function has been made at a wrong time (e.g.

closing an unopened transaction)

PDI_ERR_RIGHT 

A conflict of onwership over a content has been raised.

PDI_ERR_TYPE 

Invalid type error.

Function Documentation

◆ PDI_errmsg()

const char * PDI_errmsg ( void  )

Return a human-readabe message describing the last error that occured in PDI.

◆ PDI_errhandler()

PDI_errhandler_t PDI_errhandler ( PDI_errhandler_t  handler)

Sets the error handler to use.

PDI_asserthandler is the default handler before this function is called

Parameters
handlerthe new handler to set
Returns
the previous handler

Variable Documentation

◆ PDI_ASSERT_HANDLER

const PDI_errhandler_t PDI_ASSERT_HANDLER
extern

Prints the error message and aborts if the status is invalid.

◆ PDI_WARN_HANDLER

const PDI_errhandler_t PDI_WARN_HANDLER
extern

Prints the error message and continue if the status is invalid.

◆ PDI_NULL_HANDLER

const PDI_errhandler_t PDI_NULL_HANDLER
extern

Does nothing.