Go to the documentation of this file.
13#ifndef ML_ERROR_MACROS_H
14#define ML_ERROR_MACROS_H
30 #pragma warning(disable: 4701)
31 #pragma warning(disable: 4702)
32 #pragma warning(disable: 4710)
33 #pragma warning(disable: 4097)
34 #pragma warning(disable: 4512)
35 #pragma warning(disable: 4127)
36 #pragma warning(disable: 4711)
38 #pragma warning(disable: 4127)
58 #define ML_CATCH_RETURN
59 #define ML_CATCH_RETURN_FALSE
60 #define ML_CATCH_RETURN_NULL
61 #define ML_CATCH_RETHROW
62 #define ML_CATCH_BLOCK(__paramType) if (MLAlwaysFalse)
65 #define ML_CATCH catch(...){ MLPrintAndNotifyFatal(__FILE__, __LINE__, ML_UNKNOWN_EXCEPTION); }
66 #define ML_CATCH_RETURN catch(...){ MLPrintAndNotifyFatal(__FILE__, __LINE__, ML_UNKNOWN_EXCEPTION); return; }
67 #define ML_CATCH_RETURN_FALSE catch(...){ MLPrintAndNotifyFatal(__FILE__, __LINE__, ML_UNKNOWN_EXCEPTION); return false; }
68 #define ML_CATCH_RETURN_NULL catch(...){ MLPrintAndNotifyFatal(__FILE__, __LINE__, ML_UNKNOWN_EXCEPTION); return 0; }
69 #define ML_CATCH_RETHROW catch(...){ MLPrintAndNotifyFatal(__FILE__, __LINE__, ML_UNKNOWN_EXCEPTION); throw; }
70 #define ML_CATCH_BLOCK(__paramType) catch(__paramType)
80 #define ML_CHECK(x) if (!(x)){ MLPrintAndNotifyFatal(__FILE__, __LINE__, ML_BAD_POINTER_OR_0); }
82 #define ML_CHECK_ONLY_IN_DEBUG(x) ML_CHECK(x)
84 #define ML_CHECK_ONLY_IN_DEBUG(x)
86 #define ML_CHECK_RETURN(x) if (!(x)){ MLPrintAndNotifyFatal(__FILE__, __LINE__, ML_BAD_POINTER_OR_0); return; }
87 #define ML_CHECK_RETURN_FALSE(x) if (!(x)){ MLPrintAndNotifyFatal(__FILE__, __LINE__, ML_BAD_POINTER_OR_0); return false; }
88 #define ML_CHECK_RETURN_NULL(x) if (!(x)){ MLPrintAndNotifyFatal(__FILE__, __LINE__, ML_BAD_POINTER_OR_0); return 0; }
89 #define ML_CHECK_THROW(x) if (!(x)){ MLPrintAndNotifyFatal(__FILE__, __LINE__, ML_BAD_POINTER_OR_0); throw ML_BAD_POINTER_OR_0; }
90 #define ML_CHECK_RUNTIME_TYPE(x) if (!(x)){ MLPrintAndNotifyFatal(__FILE__, __LINE__, ML_TYPE_NOT_REGISTERED); throw ML_TYPE_NOT_REGISTERED; }
93 #define ML_HARAKIRI MLPrintAndNotifyFatal(__FILE__, __LINE__, ML_BAD_POINTER_OR_0);
102 #define ML_CHECK_FLOAT(x) if (MLValueIs0WOM(x)){ MLPrintAndNotifyFatal(__FILE__, __LINE__, ML_BAD_POINTER_OR_0); }
103 #define ML_CHECK_FLOAT_RETURN(x) if (MLValueIs0WOM(x)){ MLPrintAndNotifyFatal(__FILE__, __LINE__, ML_BAD_POINTER_OR_0); return; }
104 #define ML_CHECK_FLOAT_RETURN_FALSE(x) if (MLValueIs0WOM(x)){ MLPrintAndNotifyFatal(__FILE__, __LINE__, ML_BAD_POINTER_OR_0); return false; }
105 #define ML_CHECK_FLOAT_RETURN_NULL(x) if (MLValueIs0WOM(x)){ MLPrintAndNotifyFatal(__FILE__, __LINE__, ML_BAD_POINTER_OR_0); return 0; }
106 #define ML_CHECK_FLOAT_THROW(x) if (MLValueIs0WOM(x)){ MLPrintAndNotifyFatal(__FILE__, __LINE__, ML_BAD_POINTER_OR_0); throw ML_BAD_POINTER_OR_0; }
107 #define ML_CHECK_FLOAT_RUNTIME_TYPE(x) if (MLValueIs0WOM(x)){ MLPrintAndNotifyFatal(__FILE__, __LINE__, ML_TYPE_NOT_REGISTERED); throw ML_TYPE_NOT_REGISTERED; }
120#define _ML_INFORMATION_ADD_ON(FUNC_NAME, REASON, HANDLING)
126#define _ML_WARNING_ADD_ON(FUNC_NAME, REASON, HANDLING)
132#define _ML_ERROR_ADD_ON(FUNC_NAME, REASON, HANDLING)
138#define _ML_FATAL_ERROR_ADD_ON(FUNC_NAME, REASON, HANDLING)
145#define _ML_ERROR_SHOW_ASSERT_BOX(PARAM)
173#define _ML_PRINT_FATAL_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ, RTYPE) \
176 const ML_UTILS_NAMESPACE::RuntimeType *rtt7645 = nullptr; \
177 try{ rtt7645 = RTYPE; if (MLAlwaysFalse){ throw ML_UNKNOWN_EXCEPTION;} } catch(...){ rtt7645 = nullptr; }\
178 _ML_FATAL_ERROR_ADD_ON(FUNC_NAME, REASON, HANDLING) \
179 ML_UTILS_NAMESPACE::MLErrorOutput.printAndNotify(ML_FATAL, \
180 ML_PREFIX, "Function=", FUNC_NAME, REASON, HANDLING, \
181 __FILE__, __LINE__, RT_OBJ, rtt7645); \
182 _ML_ERROR_SHOW_ASSERT_BOX(0); \
199#define _ML_PRINT_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ, RTYPE) \
202 const ML_UTILS_NAMESPACE::RuntimeType *rtt1987 = nullptr; \
203 try{ rtt1987 = RTYPE; if (MLAlwaysFalse){ throw ML_UNKNOWN_EXCEPTION;} } catch(...){ rtt1987 = nullptr; }\
204 _ML_ERROR_ADD_ON(FUNC_NAME, REASON, HANDLING) \
205 ML_UTILS_NAMESPACE::MLErrorOutput.printAndNotify(ML_ERROR, \
206 ML_PREFIX, "Function=", FUNC_NAME, REASON, HANDLING, \
207 __FILE__, __LINE__, RT_OBJ, rtt1987); \
208 _ML_ERROR_SHOW_ASSERT_BOX(0); \
226#define _ML_PRINT_WARNING_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ, RTYPE) \
229 const ML_UTILS_NAMESPACE::RuntimeType *rt9477 = nullptr; \
230 try{ rt9477 = RTYPE; if (MLAlwaysFalse){ throw ML_UNKNOWN_EXCEPTION;} } catch(...){ rt9477 = nullptr; } \
231 _ML_WARNING_ADD_ON(FUNC_NAME, REASON, HANDLING) \
232 ML_UTILS_NAMESPACE::MLErrorOutput.printAndNotify(ML_WARNING, \
233 ML_PREFIX, "Function=", FUNC_NAME, REASON, HANDLING, \
234 __FILE__, __LINE__, RT_OBJ, rt9477); \
253#define _ML_PRINT_INFORMATION_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ, RTYPE) \
256 const ML_UTILS_NAMESPACE::RuntimeType *rtAx598 = nullptr; \
257 try{ rtAx598 = RTYPE; if (MLAlwaysFalse){ throw ML_UNKNOWN_EXCEPTION;} } catch(...){ rtAx598 = nullptr; }\
258 _ML_INFORMATION_ADD_ON(FUNC_NAME, REASON, HANDLING) \
259 ML_UTILS_NAMESPACE::MLErrorOutput.printAndNotify(ML_INFORMATION, \
260 ML_PREFIX, "Function=", FUNC_NAME, REASON, HANDLING, \
261 __FILE__, __LINE__, RT_OBJ, rtAx598); \
278#define ML_PRINT_FATAL_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) \
280 _ML_PRINT_FATAL_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ, (((RT_OBJ) || MLAlwaysFalse) ? (RT_OBJ)->getTypeId() : nullptr))
286#define ML_PRINT_FATAL_ERROR_DUMP_NON_NULL(FUNC_NAME, REASON, HANDLING, RT_OBJ) \
287 _ML_PRINT_FATAL_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ, (RT_OBJ)->getTypeId())
293#define ML_PRINT_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) \
295 _ML_PRINT_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ, (((RT_OBJ) || MLAlwaysFalse) ? (RT_OBJ)->getTypeId() : nullptr))
301#define ML_PRINT_ERROR_DUMP_NON_NULL(FUNC_NAME, REASON, HANDLING, RT_OBJ) \
302 _ML_PRINT_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ, (RT_OBJ)->getTypeId())
308#define ML_PRINT_WARNING_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) \
310 _ML_PRINT_WARNING_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ, (((RT_OBJ) || MLAlwaysFalse) ? (RT_OBJ)->getTypeId() : nullptr))
316#define ML_PRINT_INFORMATION_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) \
318 _ML_PRINT_INFORMATION_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ, (((RT_OBJ) || MLAlwaysFalse) ? (RT_OBJ)->getTypeId() : nullptr))
337#define ML_PRINT_FATAL_ERROR(FUNC_NAME, REASON, HANDLING) \
338 _ML_PRINT_FATAL_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, nullptr, nullptr)
346#define ML_PRINT_ERROR(FUNC_NAME, REASON, HANDLING) \
347 _ML_PRINT_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, nullptr, nullptr)
355#define ML_PRINT_WARNING(FUNC_NAME, REASON, HANDLING) \
356 _ML_PRINT_WARNING_DUMP(FUNC_NAME, REASON, HANDLING, nullptr, nullptr)
364#define ML_PRINT_INFORMATION(FUNC_NAME, REASON, HANDLING) \
365 _ML_PRINT_INFORMATION_DUMP(FUNC_NAME, REASON, HANDLING, nullptr, nullptr)
372#define ML_PRINT_INFO(FUNC_NAME, HANDLING) \
373 _ML_PRINT_INFORMATION_DUMP(FUNC_NAME, ML_RESULT_OK, HANDLING, nullptr, nullptr)