* mu-util: add some new exception handler macros

This commit is contained in:
Dirk-Jan C. Binnema
2011-09-03 10:50:15 +03:00
parent 53c2c91d3a
commit 8fff492414

View File

@ -274,6 +274,15 @@ typedef gpointer XapianEnquire;
* don't repeat these catch blocks everywhere... * don't repeat these catch blocks everywhere...
* *
*/ */
#define MU_STORE_CATCH_BLOCK_RETURN(GE,R) \
catch (const MuStoreError& merr) { \
g_set_error ((GE), 0, merr.mu_error(), "%s", \
merr.what().c_str()); \
return (R); \
} \
#define MU_XAPIAN_CATCH_BLOCK \ #define MU_XAPIAN_CATCH_BLOCK \
catch (const Xapian::Error &xerr) { \ catch (const Xapian::Error &xerr) { \
g_critical ("%s: xapian error '%s'", \ g_critical ("%s: xapian error '%s'", \
@ -304,7 +313,6 @@ typedef gpointer XapianEnquire;
} }
#define MU_XAPIAN_CATCH_BLOCK_RETURN(R) \ #define MU_XAPIAN_CATCH_BLOCK_RETURN(R) \
catch (const Xapian::Error &xerr) { \ catch (const Xapian::Error &xerr) { \
g_critical ("%s: xapian error '%s'", \ g_critical ("%s: xapian error '%s'", \
@ -349,6 +357,10 @@ typedef gpointer XapianEnquire;
} G_STMT_END } G_STMT_END
#define MU_G_ERROR_CODE(GE) ((GE)&&(*(GE))?(*(GE))->code:MU_ERROR)
enum _MuError { enum _MuError {
/* no error at all! */ /* no error at all! */
MU_OK = 0, MU_OK = 0,
@ -374,6 +386,13 @@ enum _MuError {
MU_ERROR_XAPIAN_CORRUPTION = 17, MU_ERROR_XAPIAN_CORRUPTION = 17,
/* can't get write lock */ /* can't get write lock */
MU_ERROR_XAPIAN_CANNOT_GET_WRITELOCK = 18, MU_ERROR_XAPIAN_CANNOT_GET_WRITELOCK = 18,
/* database is empty */
MU_ERROR_XAPIAN_IS_EMPTY = 19,
/* could not write */
MU_ERROR_XAPIAN_STORE_FAILED = 20,
/* could not remove */
MU_ERROR_XAPIAN_REMOVE_FAILED = 21,
/* GMime related errors */ /* GMime related errors */
@ -398,6 +417,7 @@ enum _MuError {
MU_ERROR_FILE_READDIR_FAILED = 78, MU_ERROR_FILE_READDIR_FAILED = 78,
MU_ERROR_FILE_INVALID_SOURCE = 79, MU_ERROR_FILE_INVALID_SOURCE = 79,
MU_ERROR_FILE_TARGET_EQUALS_SOURCE = 80, MU_ERROR_FILE_TARGET_EQUALS_SOURCE = 80,
MU_ERROR_FILE_CANNOT_WRITE = 81,
/* not really an error, used in callbacks */ /* not really an error, used in callbacks */
MU_STOP = 99, MU_STOP = 99,