*
* This module is a small ISO-C++ style exception handling library
* for use in the ISO-C language. It allows you to use the paradigm
*
* This module is a small ISO-C++ style exception handling library
* for use in the ISO-C language. It allows you to use the paradigm
* These features are brought to you by a modified version of the libex
* library, one of the numerous masterpiece of Ralf S. Engelschall.
*
* These features are brought to you by a modified version of the libex
* library, one of the numerous masterpiece of Ralf S. Engelschall.
*
- * In SimGrid, exceptions is a triple <\a msg , \a category , \a value>
+ * In SimGrid, an exception is a triple <\a msg , \a category , \a value>
* where \a msg is a human-readable text describing the exceptional
* condition, \a code an integer describing what went wrong and \a value
* providing a sort of sub-category. (this is different in the original libex).
* where \a msg is a human-readable text describing the exceptional
* condition, \a code an integer describing what went wrong and \a value
* providing a sort of sub-category. (this is different in the original libex).
* following code which shows some pitfalls and contains many errors (assuming
* a mallocex() function which throws an exception if malloc(3) fails):
*
* following code which shows some pitfalls and contains many errors (assuming
* a mallocex() function which throws an exception if malloc(3) fails):
*
- { NULL, 0, { /* content */ NULL, 0, 0, \
+ { NULL, 0, { /* content */ NULL, unknown_error, 0, \
/* throw point*/ NULL, NULL, NULL, 0, NULL,\
/* backtrace */ {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},0 } }
#define XBT_CTX_INITIALIZE(ctx) \
/* throw point*/ NULL, NULL, NULL, 0, NULL,\
/* backtrace */ {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},0 } }
#define XBT_CTX_INITIALIZE(ctx) \
-#define THROW0(c,v,m) _THROW(c,v,bprintf(m))
+/** @brief Builds and throws an exception with a string taking no arguments
+ @hideinitializer */
+#define THROW0(c,v,m) _THROW(c,v,(m?bprintf(m):NULL))
+/** @brief Builds and throws an exception with a string taking one argument
+ @hideinitializer */
#define THROW1(c,v,m,a1) _THROW(c,v,bprintf(m,a1))
#define THROW1(c,v,m,a1) _THROW(c,v,bprintf(m,a1))
#define THROW2(c,v,m,a1,a2) _THROW(c,v,bprintf(m,a1,a2))
#define THROW2(c,v,m,a1,a2) _THROW(c,v,bprintf(m,a1,a2))
#define THROW3(c,v,m,a1,a2,a3) _THROW(c,v,bprintf(m,a1,a2,a3))
#define THROW3(c,v,m,a1,a2,a3) _THROW(c,v,bprintf(m,a1,a2,a3))
#define THROW4(c,v,m,a1,a2,a3,a4) _THROW(c,v,bprintf(m,a1,a2,a3,a4))
#define THROW4(c,v,m,a1,a2,a3,a4) _THROW(c,v,bprintf(m,a1,a2,a3,a4))
#define THROW5(c,v,m,a1,a2,a3,a4,a5) _THROW(c,v,bprintf(m,a1,a2,a3,a4,a5))
#define THROW5(c,v,m,a1,a2,a3,a4,a5) _THROW(c,v,bprintf(m,a1,a2,a3,a4,a5))
#define THROW6(c,v,m,a1,a2,a3,a4,a5,a6) _THROW(c,v,bprintf(m,a1,a2,a3,a4,a5,a6))
#define THROW_IMPOSSIBLE THROW0(unknown_error,0,"The Impossible Did Happen (yet again)")
#define THROW6(c,v,m,a1,a2,a3,a4,a5,a6) _THROW(c,v,bprintf(m,a1,a2,a3,a4,a5,a6))
#define THROW_IMPOSSIBLE THROW0(unknown_error,0,"The Impossible Did Happen (yet again)")
#define THROW_UNIMPLEMENTED THROW1(unknown_error,0,"Function %s unimplemented",__FUNCTION__)
#define THROW_UNIMPLEMENTED THROW1(unknown_error,0,"Function %s unimplemented",__FUNCTION__)
#define RETHROW1(msg,a) _XBT_PRE_RETHROW msg,a, _XBT_POST_RETHROW
#define RETHROW1(msg,a) _XBT_PRE_RETHROW msg,a, _XBT_POST_RETHROW
#define RETHROW2(msg,a,b) _XBT_PRE_RETHROW msg,a,b, _XBT_POST_RETHROW
#define RETHROW2(msg,a,b) _XBT_PRE_RETHROW msg,a,b, _XBT_POST_RETHROW
#define RETHROW3(msg,a,b,c) _XBT_PRE_RETHROW msg,a,b,c, _XBT_POST_RETHROW
#define RETHROW3(msg,a,b,c) _XBT_PRE_RETHROW msg,a,b,c, _XBT_POST_RETHROW
#define RETHROW4(msg,a,b,c,d) _XBT_PRE_RETHROW msg,a,b,c, _XBT_POST_RETHROW
#define RETHROW4(msg,a,b,c,d) _XBT_PRE_RETHROW msg,a,b,c, _XBT_POST_RETHROW
#define RETHROW5(msg,a,b,c,d,e) _XBT_PRE_RETHROW msg,a,b,c,d,e _XBT_POST_RETHROW
#define RETHROW5(msg,a,b,c,d,e) _XBT_PRE_RETHROW msg,a,b,c,d,e _XBT_POST_RETHROW