Below is sample program to demonstrate how to use exception handling.
34static void randomly_throw_exception()
40static void *my_malloc(
size_t size)
42 void *ptr = malloc(size);
48static int test_exception()
53 void *data = my_malloc(200);
55 randomly_throw_exception();
61 printf(
"Caught exception %d (%s)\n",
79 return test_exception();
#define PJ_CATCH_ANY
Definition: except.h:388
#define PJ_TRY
Definition: except.h:373
#define PJ_THROW(exception_id)
Definition: except.h:402
#define PJ_GET_EXCEPTION()
Definition: except.h:409
#define PJ_END
Definition: except.h:394
#define PJ_USE_EXCEPTION
Definition: except.h:367
pj_status_t pj_init(void)
int pj_status_t
Definition: types.h:68
int pj_exception_id_t
Definition: types.h:276
const char * pj_exception_id_name(pj_exception_id_t id)
pj_status_t pj_exception_id_alloc(const char *name, pj_exception_id_t *id)