[MOAB-dev] commit/MOAB: danwu: Updated macro-based error handling interface.
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu Mar 13 15:13:54 CDT 2014
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/fcc05cd64a00/
Changeset: fcc05cd64a00
Branch: error_handling_enhancement
User: danwu
Date: 2014-03-13 21:13:08
Summary: Updated macro-based error handling interface.
Affected #: 1 file
diff --git a/src/moab/ErrorHandler.hpp b/src/moab/ErrorHandler.hpp
index 42c1758..2adc868 100644
--- a/src/moab/ErrorHandler.hpp
+++ b/src/moab/ErrorHandler.hpp
@@ -120,121 +120,186 @@ ErrorCode MBError(int line, const char* func, const char* file, const char* dir,
#endif
#ifdef USE_ERROR_INFO_CLASS
+//! Set a new error with passed error code and passed error message string
#define SET_ERR(err_code, err_msg) \
return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, ErrorInfo(err_code, err_msg), MB_ERROR_TYPE_NEW_LOCAL)
-#define SET_ERR1(err_info) \
- return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, err_info, MB_ERROR_TYPE_NEW_LOCAL)
-
+//! Set a new error with passed error code and passed error message string stream
#define SET_ERR_STR(err_code, err_msg_str) \
- ErrorInfo err_info; \
- err_info << err_msg_str; \
- return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, err_info, MB_ERROR_TYPE_NEW_LOCAL)
+ do { \
+ ErrorInfo err_info(err_code); \
+ err_info << err_msg_str; \
+ return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, err_info, MB_ERROR_TYPE_NEW_LOCAL); \
+ } while (false)
+//! Set a new global error with passed error code and passed error message string
#define SET_GLB_ERR(err_code, err_msg) \
return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, ErrorInfo(err_code, err_msg), MB_ERROR_TYPE_NEW_GLOBAL)
-#define SET_GLB_ERR1(err_info) \
- return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, err_info, MB_ERROR_TYPE_NEW_GLOBAL)
-
+//! Set a new global error with passed error code and passed error message string stream
#define SET_GLB_ERR_STR(err_code, err_msg_str) \
- ErrorInfo err_info; \
- err_info << err_msg_str; \
- return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, err_info, MB_ERROR_TYPE_NEW_GLOBAL)
+ do { \
+ ErrorInfo err_info(err_code); \
+ err_info << err_msg_str; \
+ return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, err_info, MB_ERROR_TYPE_NEW_GLOBAL); \
+ } while (false)
+//! Check returned error code against MB_SUCCESS
#define CHK_ERR(err_info) \
do { \
if (MB_SUCCESS != err_info) \
return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, err_info, MB_ERROR_TYPE_EXISTING); \
} while (false)
+//! Check returned error code against MB_SUCCESS
+//! Set a new error with the returned error code and passed error message string
#define CHK_ERR1(err_info, err_msg_to_set) \
do { \
if (MB_SUCCESS != err_info) { \
- err_info.set_error_msg(err_msg_to_set); \
- SET_ERR(err_info); \
+ ErrorCode err_code = err_info.get_error_code(); \
+ SET_ERR(err_code, err_msg_to_set); \
} \
} while (false)
-#define CHK_ERR2(err_info, err_code_to_set, err_msg_to_set) \
+//! Check returned error code against MB_SUCCESS
+//! Set a new error with the returned error code and passed error message string stream
+#define CHK_ERR1_STR(err_info, err_msg_str_to_set) \
do { \
if (MB_SUCCESS != err_info) { \
- err_info.set_error_code(err_code_to_set); \
- err_info.set_error_msg(err_msg_to_set); \
- SET_ERR(err_info); \
+ ErrorCode err_code = err_info.get_error_code(); \
+ SET_ERR_STR(err_code, err_msg_str_to_set); \
} \
} while (false)
+//! Check returned error code against MB_SUCCESS
+//! Set a new error with passed error code and passed error message string
+#define CHK_ERR2(err_info, err_code_to_set, err_msg_to_set) \
+ do { \
+ if (MB_SUCCESS != err_info) \
+ SET_ERR(err_code_to_set, err_msg_to_set); \
+ } while (false)
+
+//! Check returned error code against MB_SUCCESS
+//! Set a new error with passed error code and passed error message string stream
+#define CHK_ERR2_STR(err_info, err_code_to_set, err_msg_str_to_set) \
+ do { \
+ if (MB_SUCCESS != err_info) \
+ SET_ERR_STR(err_code_to_set, err_msg_str_to_set); \
+ } while (false)
+
+//! Check returned error code against an expected one
+//! Set a new error with default error code and default error message string
#define CHK_EQL(err_info, exp_err_code) \
do { \
- if (exp_err_code != err_info) { \
- err_info.set_error_code(MB_FAILURE); \
- err_info.set_error_msg("Returned error code is not expected"); \
- SET_ERR(err_info); \
- } \
+ if (exp_err_code != err_info) \
+ SET_ERR(MB_FAILURE, "Returned error code is not expected"); \
} while (false)
+//! Check returned error code against an expected one
+//! Set a new error with default error code and passed error message string
#define CHK_EQL1(err_info, exp_err_code, err_msg_to_set) \
do { \
- if (exp_err_code != err_info) { \
- err_info.set_error_code(MB_FAILURE); \
- err_info.set_error_msg(err_msg_to_set); \
- SET_ERR(err_info); \
- } \
+ if (exp_err_code != err_info) \
+ SET_ERR(MB_FAILURE, err_msg_to_set); \
+ } while (false)
+
+//! Check returned error code against an expected one
+//! Set a new error with default error code and passed error message string stream
+#define CHK_EQL1_STR(err_info, exp_err_code, err_msg_str_to_set) \
+ do { \
+ if (exp_err_code != err_info) \
+ SET_ERR_STR(MB_FAILURE, err_msg_str_to_set); \
} while (false)
+//! Check returned error code against an expected one
+//! Set a new error with passed error code and passed error message string
#define CHK_EQL2(err_info, exp_err_code, err_code_to_set, err_msg_to_set) \
do { \
- if (exp_err_code != err_info) { \
- err_info.set_error_code(err_code_to_set); \
- err_info.set_error_msg(err_msg_to_set); \
- SET_ERR(err_info); \
- } \
+ if (exp_err_code != err_info) \
+ SET_ERR(err_code_to_set, err_msg_to_set); \
+ } while (false)
+
+//! Check returned error code against an expected one
+//! Set a new error with passed error code and passed error message string stream
+#define CHK_EQL2_STR(err_info, exp_err_code, err_code_to_set, err_msg_str_to_set) \
+ do { \
+ if (exp_err_code != err_info) \
+ SET_ERR_STR(err_code_to_set, err_msg_str_to_set); \
} while (false)
#else
+//! Set a new error with passed error code and passed error message string
#define SET_ERR(err_code, err_msg) \
return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, err_code, err_msg, MB_ERROR_TYPE_NEW_LOCAL)
+//! Set a new error with passed error code and passed error message string stream
#define SET_ERR_STR(err_code, err_msg_str) \
- std::ostringstream ostr; \
- ostr << err_msg_str; \
- return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, err_code, ostr.str().c_str(), MB_ERROR_TYPE_NEW_LOCAL)
+ do { \
+ std::ostringstream ostr; \
+ ostr << err_msg_str; \
+ return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, err_code, ostr.str().c_str(), MB_ERROR_TYPE_NEW_LOCAL); \
+ } while (false)
+//! Set a new global error with passed error code and passed error message string
#define SET_GLB_ERR(err_code, err_msg) \
return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, err_code, err_msg, MB_ERROR_TYPE_NEW_GLOBAL)
+//! Set a new global error with passed error code and passed error message string stream
#define SET_GLB_ERR_STR(err_code, err_msg_str) \
- std::ostringstream ostr; \
- ostr << err_msg_str; \
- return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, err_code, ostr.str().c_str(), MB_ERROR_TYPE_NEW_GLOBAL)
+ do { \
+ std::ostringstream ostr; \
+ ostr << err_msg_str; \
+ return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, err_code, ostr.str().c_str(), MB_ERROR_TYPE_NEW_GLOBAL); \
+ } while (false)
+//! Check returned error code against MB_SUCCESS
#define CHK_ERR(err_code) \
do { \
if (MB_SUCCESS != err_code) \
return MBError(__LINE__, __func__, __FILENAME__, __SDIR__, err_code, "", MB_ERROR_TYPE_EXISTING); \
} while (false)
+//! Check returned error code against MB_SUCCESS
+//! Set a new error with the returned error code and passed error message string
#define CHK_ERR1(err_code, err_msg_to_set) \
do { \
- if (MB_SUCCESS != err_code) { \
+ if (MB_SUCCESS != err_code) \
SET_ERR(err_code, err_msg_to_set); \
- } \
} while (false)
+//! Check returned error code against MB_SUCCESS
+//! Set a new error with the returned error code and passed error message string stream
+#define CHK_ERR1_STR(err_code, err_msg_str_to_set) \
+ do { \
+ if (MB_SUCCESS != err_code) \
+ SET_ERR_STR(err_code, err_msg_str_to_set); \
+ } while (false)
+
+//! Check returned error code against MB_SUCCESS
+//! Set a new error with passed error code and passed error message string
#define CHK_ERR2(err_code, err_code_to_set, err_msg_to_set) \
do { \
- if (MB_SUCCESS != err_code) { \
+ if (MB_SUCCESS != err_code) \
SET_ERR(err_code_to_set, err_msg_to_set); \
- } \
} while (false)
+//! Check returned error code against MB_SUCCESS
+//! Set a new error with passed error code and passed error message string stream
+#define CHK_ERR2_STR(err_code, err_code_to_set, err_msg_str_to_set) \
+ do { \
+ if (MB_SUCCESS != err_code) \
+ SET_ERR_STR(err_code_to_set, err_msg_str_to_set); \
+ } while (false)
+
+//! Check returned error code against an expected one
+//! Set a new error with default error code and default error message string
#define CHK_EQL(err_code, exp_err_code) \
do { \
- if (exp_err_code != err_code) { \
+ if (exp_err_code != err_code) \
SET_ERR(MB_FAILURE, "Returned error code is not expected"); \
- } \
} while (false)
+//! Check returned error code against an expected one
+//! Set a new error with default error code and passed error message string
#define CHK_EQL1(err_code, exp_err_code, err_msg_to_set) \
do { \
if (exp_err_code != err_code) { \
@@ -242,11 +307,28 @@ ErrorCode MBError(int line, const char* func, const char* file, const char* dir,
} \
} while (false)
+//! Check returned error code against an expected one
+//! Set a new error with default error code and passed error message string stream
+#define CHK_EQL1_STR(err_code, exp_err_code, err_msg_str_to_set) \
+ do { \
+ if (exp_err_code != err_code) \
+ SET_ERR_STR(MB_FAILURE, err_msg_str_to_set); \
+ } while (false)
+
+//! Check returned error code against an expected one
+//! Set a new error with passed error code and passed error message string
#define CHK_EQL2(err_code, exp_err_code, err_code_to_set, err_msg_to_set) \
do { \
- if (exp_err_code != err_code) { \
+ if (exp_err_code != err_code) \
SET_ERR(err_code_to_set, err_msg_to_set); \
- } \
+ } while (false)
+
+//! Check returned error code against an expected one
+//! Set a new error with passed error code and passed error message string stream
+#define CHK_EQL2_STR(err_code, exp_err_code, err_code_to_set, err_msg_str_to_set) \
+ do { \
+ if (exp_err_code != err_code) \
+ SET_ERR_STR(err_code_to_set, err_msg_str_to_set); \
} while (false)
#endif
Repository URL: https://bitbucket.org/fathomteam/moab/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the moab-dev
mailing list