mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-26 19:23:26 -03:00
util: Add StrFormatInternalBug and STR_INTERNAL_BUG
This commit is contained in:
parent
bcee94d107
commit
c6e7f224c1
2 changed files with 9 additions and 2 deletions
|
@ -14,10 +14,13 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <string>
|
#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)
|
NonFatalCheckError::NonFatalCheckError(const char* msg, const char* file, int line, const char* func)
|
||||||
: std::runtime_error{
|
: std::runtime_error{StrFormatInternalBug(msg, file, line, func)}
|
||||||
strprintf("Internal bug detected: \"%s\"\n%s:%d (%s)\nPlease report this issue here: %s\n", msg, file, line, func, PACKAGE_BUGREPORT)}
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,16 @@
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
std::string StrFormatInternalBug(const char* msg, const char* file, int line, const char* func);
|
||||||
|
|
||||||
class NonFatalCheckError : public std::runtime_error
|
class NonFatalCheckError : public std::runtime_error
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NonFatalCheckError(const char* msg, const char* file, int line, const char* func);
|
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() */
|
/** Helper for CHECK_NONFATAL() */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T&& inline_check_non_fatal(LIFETIMEBOUND T&& val, const char* file, int line, const char* func, const char* assertion)
|
T&& inline_check_non_fatal(LIFETIMEBOUND T&& val, const char* file, int line, const char* func, const char* assertion)
|
||||||
|
|
Loading…
Add table
Reference in a new issue