Bitcoin Core  27.99.0
P2P Digital Currency
check.cpp
Go to the documentation of this file.
1 // Copyright (c) 2022 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <util/check.h>
6 
7 #if defined(HAVE_CONFIG_H)
9 #endif
10 
11 #include <clientversion.h>
12 #include <tinyformat.h>
13 
14 #include <cstdio>
15 #include <cstdlib>
16 #include <string>
17 #include <string_view>
18 
19 std::string StrFormatInternalBug(std::string_view msg, std::string_view file, int line, std::string_view func)
20 {
21  return strprintf("Internal bug detected: %s\n%s:%d (%s)\n"
22  "%s %s\n"
23  "Please report this issue here: %s\n",
24  msg, file, line, func, PACKAGE_NAME, FormatFullVersion(), PACKAGE_BUGREPORT);
25 }
26 
27 NonFatalCheckError::NonFatalCheckError(std::string_view msg, std::string_view file, int line, std::string_view func)
28  : std::runtime_error{StrFormatInternalBug(msg, file, line, func)}
29 {
30 }
31 
32 void assertion_fail(std::string_view file, int line, std::string_view func, std::string_view assertion)
33 {
34  auto str = strprintf("%s:%s %s: Assertion `%s' failed.\n", file, line, func, assertion);
35  fwrite(str.data(), 1, str.size(), stderr);
36  std::abort();
37 }
#define PACKAGE_NAME
#define PACKAGE_BUGREPORT
std::string StrFormatInternalBug(std::string_view msg, std::string_view file, int line, std::string_view func)
Definition: check.cpp:19
void assertion_fail(std::string_view file, int line, std::string_view func, std::string_view assertion)
Helper for Assert()
Definition: check.cpp:32
NonFatalCheckError(std::string_view msg, std::string_view file, int line, std::string_view func)
Definition: check.cpp:27
std::string FormatFullVersion()
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1162