diff options
author | MarcoFalke <falke.marco@gmail.com> | 2022-12-01 12:20:45 -0500 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2022-12-01 12:22:47 -0500 |
commit | c6e7f224c119f47af250a9e0c5b185cb98b30c4c (patch) | |
tree | 724f459c1ca757c70330872281b6b782361e57d9 /src/util | |
parent | bcee94d1078ccb7812dc12bfcb0c9d9a799a6d3b (diff) | |
download | bitcoin-c6e7f224c119f47af250a9e0c5b185cb98b30c4c.tar.xz |
util: Add StrFormatInternalBug and STR_INTERNAL_BUG
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/check.cpp | 7 | ||||
-rw-r--r-- | src/util/check.h | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/util/check.cpp b/src/util/check.cpp index e50d6087d0..c4982ff4ad 100644 --- a/src/util/check.cpp +++ b/src/util/check.cpp @@ -14,10 +14,13 @@ #include <cstdlib> #include <string> +std::string StrFormatInternalBug(const char* msg, const char* file, int line, const char* func) +{ + return strprintf("Internal bug detected: \"%s\"\n%s:%d (%s)\nPlease report this issue here: %s\n", msg, file, line, func, PACKAGE_BUGREPORT); +} NonFatalCheckError::NonFatalCheckError(const char* msg, const char* file, int line, const char* func) - : std::runtime_error{ - strprintf("Internal bug detected: \"%s\"\n%s:%d (%s)\nPlease report this issue here: %s\n", msg, file, line, func, PACKAGE_BUGREPORT)} + : std::runtime_error{StrFormatInternalBug(msg, file, line, func)} { } diff --git a/src/util/check.h b/src/util/check.h index b6c03bed2a..b791944502 100644 --- a/src/util/check.h +++ b/src/util/check.h @@ -10,12 +10,16 @@ #include <stdexcept> #include <utility> +std::string StrFormatInternalBug(const char* msg, const char* file, int line, const char* func); + class NonFatalCheckError : public std::runtime_error { public: NonFatalCheckError(const char* msg, const char* file, int line, const char* func); }; +#define STR_INTERNAL_BUG(msg) StrFormatInternalBug((msg), __FILE__, __LINE__, __func__) + /** Helper for CHECK_NONFATAL() */ template <typename T> T&& inline_check_non_fatal(LIFETIMEBOUND T&& val, const char* file, int line, const char* func, const char* assertion) |