error.h File Reference
`#include <proton/import_export.h>`
`#include <stdarg.h>`

Go to the source code of this file.

## Macros

#define | PN_OK (0)
#define | PN_EOS (-1)
#define | PN_ERR (-2)
#define | PN_OVERFLOW (-3)
#define | PN_UNDERFLOW (-4)
#define | PN_STATE_ERR (-5)
#define | PN_ARG_ERR (-6)
#define | PN_TIMEOUT (-7)
#define | PN_INTR (-8)
#define | PN_INPROGRESS (-9)
#define | PN_OUT_OF_MEMORY (-10)
#define | PN_RETURN_IF_ERROR(x)

## Typedefs

typedef struct pn_error_t | pn_error_t
| A pn_error_t has an int error `code` and some string `text` to describe the error. More...

## Functions

PN_EXTERN const char * | pn_code (int code)
PN_EXTERN pn_error_t * | pn_error (void)
PN_EXTERN void | pn_error_free (pn_error_t *error)
PN_EXTERN void | pn_error_clear (pn_error_t *error)
| Reset the error to a "no error" state with code == 0. More...
PN_EXTERN int | pn_error_set (pn_error_t *error, int code, const char *text)
| Set the error code and text. More...
PN_EXTERN int | pn_error_vformat (pn_error_t *error, int code, const char *fmt, va_list ap)
| Set the code and set the text using a printf-style formatted string. More...
PN_EXTERN int | pn_error_format (pn_error_t *error, int code, const char *fmt,...)
| Set the code and set the text using a printf-style formatted string. More...
PN_EXTERN int | pn_error_code (pn_error_t *error)
PN_EXTERN const char * | pn_error_text (pn_error_t *error)
PN_EXTERN int | pn_error_copy (pn_error_t *error, pn_error_t *src)

## Macro Definition Documentation

## PN_ARG_ERR

#define PN_ARG_ERR (-6)

## PN_EOS

#define PN_EOS (-1)

## PN_ERR

#define PN_ERR (-2)

## PN_INPROGRESS

#define PN_INPROGRESS (-9)

## PN_INTR

#define PN_INTR (-8)

## PN_OK

#define PN_OK (0)

## PN_OUT_OF_MEMORY

#define PN_OUT_OF_MEMORY (-10)

## PN_OVERFLOW

#define PN_OVERFLOW (-3)

## PN_RETURN_IF_ERROR

#define PN_RETURN_IF_ERROR | ( |  | x | ) |

Value:
do {\
int r = (x);\
if (r < 0) return r; \
} while (0)

## PN_STATE_ERR

#define PN_STATE_ERR (-5)

## PN_TIMEOUT

#define PN_TIMEOUT (-7)

## PN_UNDERFLOW

#define PN_UNDERFLOW (-4)

## Typedef Documentation

## pn_error_t

typedef struct pn_error_t pn_error_t

A pn_error_t has an int error `code` and some string `text` to describe the error.

## Function Documentation

## pn_code()

PN_EXTERN const char* pn_code | ( | int | code | ) |

Returns
  name of the error code. Returned pointer is to a static constant, do not delete.

## pn_error()

PN_EXTERN pn_error_t* pn_error | ( | void |  | ) |

## pn_error_clear()

PN_EXTERN void pn_error_clear | ( | pn_error_t * | error | ) |

Reset the error to a "no error" state with code == 0.

## pn_error_code()

PN_EXTERN int pn_error_code | ( | pn_error_t * | error | ) |

Returns
  the error code.

## pn_error_copy()

PN_EXTERN int pn_error_copy | ( | pn_error_t * | error,
|  | pn_error_t * | src
| ) |  |

## pn_error_format()

PN_EXTERN int pn_error_format | ( | pn_error_t * | error,
|  | int | code,
|  | const char * | fmt,
|  |  | ...
| ) |  |

Set the code and set the text using a printf-style formatted string.

## pn_error_free()

PN_EXTERN void pn_error_free | ( | pn_error_t * | error | ) |

## pn_error_set()

PN_EXTERN int pn_error_set | ( | pn_error_t * | error,
|  | int | code,
|  | const char * | text
| ) |  |

Set the error code and text.

Makes a copy of text.

## pn_error_text()

PN_EXTERN const char* pn_error_text | ( | pn_error_t * | error | ) |

Returns
  the error text. Returned pointer is owned by the pn_error_t.

## pn_error_vformat()

PN_EXTERN int pn_error_vformat | ( | pn_error_t * | error,
|  | int | code,
|  | const char * | fmt,
|  | va_list | ap
| ) |  |

Set the code and set the text using a printf-style formatted string.