Skip to content

Commit c6e7f22

Browse files
MarcoFalkeachow101
authored andcommitted
util: Add StrFormatInternalBug and STR_INTERNAL_BUG
1 parent bcee94d commit c6e7f22

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/util/check.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414
#include <cstdlib>
1515
#include <string>
1616

17+
std::string StrFormatInternalBug(const char* msg, const char* file, int line, const char* func)
18+
{
19+
return strprintf("Internal bug detected: \"%s\"\n%s:%d (%s)\nPlease report this issue here: %s\n", msg, file, line, func, PACKAGE_BUGREPORT);
20+
}
1721

1822
NonFatalCheckError::NonFatalCheckError(const char* msg, const char* file, int line, const char* func)
19-
: std::runtime_error{
20-
strprintf("Internal bug detected: \"%s\"\n%s:%d (%s)\nPlease report this issue here: %s\n", msg, file, line, func, PACKAGE_BUGREPORT)}
23+
: std::runtime_error{StrFormatInternalBug(msg, file, line, func)}
2124
{
2225
}
2326

src/util/check.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@
1010
#include <stdexcept>
1111
#include <utility>
1212

13+
std::string StrFormatInternalBug(const char* msg, const char* file, int line, const char* func);
14+
1315
class NonFatalCheckError : public std::runtime_error
1416
{
1517
public:
1618
NonFatalCheckError(const char* msg, const char* file, int line, const char* func);
1719
};
1820

21+
#define STR_INTERNAL_BUG(msg) StrFormatInternalBug((msg), __FILE__, __LINE__, __func__)
22+
1923
/** Helper for CHECK_NONFATAL() */
2024
template <typename T>
2125
T&& inline_check_non_fatal(LIFETIMEBOUND T&& val, const char* file, int line, const char* func, const char* assertion)

0 commit comments

Comments
 (0)