@@ -20,8 +20,6 @@ class NonFatalCheckError : public std::runtime_error
20
20
NonFatalCheckError (std::string_view msg, std::string_view file, int line, std::string_view func);
21
21
};
22
22
23
- #define STR_INTERNAL_BUG (msg ) StrFormatInternalBug((msg), __FILE__, __LINE__, __func__)
24
-
25
23
/* * Helper for CHECK_NONFATAL() */
26
24
template <typename T>
27
25
T&& 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
32
30
return std::forward<T>(val);
33
31
}
34
32
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
-
49
33
#if defined(NDEBUG)
50
34
#error "Cannot compile without assertions!"
51
35
#endif
@@ -69,6 +53,25 @@ T&& inline_assertion_check(LIFETIMEBOUND T&& val, [[maybe_unused]] const char* f
69
53
return std::forward<T>(val);
70
54
}
71
55
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
+
72
75
/* * Identity function. Abort if the value compares equal to zero */
73
76
#define Assert (val ) inline_assertion_check<true >(val, __FILE__, __LINE__, __func__, #val)
74
77
@@ -91,4 +94,6 @@ T&& inline_assertion_check(LIFETIMEBOUND T&& val, [[maybe_unused]] const char* f
91
94
throw NonFatalCheckError ( \
92
95
" Unreachable code reached (non-fatal)" , __FILE__, __LINE__, __func__)
93
96
97
+ // NOLINTEND(bugprone-lambda-function-name)
98
+
94
99
#endif // BITCOIN_UTIL_CHECK_H
0 commit comments