@@ -20,8 +20,6 @@ class NonFatalCheckError : public std::runtime_error
2020 NonFatalCheckError (std::string_view msg, std::string_view file, int line, std::string_view func);
2121};
2222
23- #define STR_INTERNAL_BUG (msg ) StrFormatInternalBug((msg), __FILE__, __LINE__, __func__)
24-
2523/* * Helper for CHECK_NONFATAL() */
2624template <typename T>
2725T&& inline_check_non_fatal(LIFETIMEBOUND T&& val, const char * file, int line, const char * func, const char * assertion)
@@ -32,20 +30,6 @@ T&& inline_check_non_fatal(LIFETIMEBOUND T&& val, const char* file, int line, co
3230 return std::forward<T>(val);
3331}
3432
35- /* *
36- * Identity function. Throw a NonFatalCheckError when the condition evaluates to false
37- *
38- * This should only be used
39- * - where the condition is assumed to be true, not for error handling or validating user input
40- * - where a failure to fulfill the condition is recoverable and does not abort the program
41- *
42- * For example in RPC code, where it is undesirable to crash the whole program, this can be generally used to replace
43- * asserts or recoverable logic errors. A NonFatalCheckError in RPC code is caught and passed as a string to the RPC
44- * caller, which can then report the issue to the developers.
45- */
46- #define CHECK_NONFATAL (condition ) \
47- inline_check_non_fatal (condition, __FILE__, __LINE__, __func__, #condition)
48-
4933#if defined(NDEBUG)
5034#error "Cannot compile without assertions!"
5135#endif
@@ -69,6 +53,25 @@ T&& inline_assertion_check(LIFETIMEBOUND T&& val, [[maybe_unused]] const char* f
6953 return std::forward<T>(val);
7054}
7155
56+ // All macros may use __func__ inside a lambda, so put them under nolint.
57+ // NOLINTBEGIN(bugprone-lambda-function-name)
58+
59+ #define STR_INTERNAL_BUG (msg ) StrFormatInternalBug((msg), __FILE__, __LINE__, __func__)
60+
61+ /* *
62+ * Identity function. Throw a NonFatalCheckError when the condition evaluates to false
63+ *
64+ * This should only be used
65+ * - where the condition is assumed to be true, not for error handling or validating user input
66+ * - where a failure to fulfill the condition is recoverable and does not abort the program
67+ *
68+ * For example in RPC code, where it is undesirable to crash the whole program, this can be generally used to replace
69+ * asserts or recoverable logic errors. A NonFatalCheckError in RPC code is caught and passed as a string to the RPC
70+ * caller, which can then report the issue to the developers.
71+ */
72+ #define CHECK_NONFATAL (condition ) \
73+ inline_check_non_fatal (condition, __FILE__, __LINE__, __func__, #condition)
74+
7275/* * Identity function. Abort if the value compares equal to zero */
7376#define Assert (val ) inline_assertion_check<true >(val, __FILE__, __LINE__, __func__, #val)
7477
@@ -91,4 +94,6 @@ T&& inline_assertion_check(LIFETIMEBOUND T&& val, [[maybe_unused]] const char* f
9194 throw NonFatalCheckError ( \
9295 " Unreachable code reached (non-fatal)" , __FILE__, __LINE__, __func__)
9396
97+ // NOLINTEND(bugprone-lambda-function-name)
98+
9499#endif // BITCOIN_UTIL_CHECK_H
0 commit comments