/root/bitcoin/src/util/check.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | #include <bitcoin-build-config.h> // IWYU pragma: keep |
8 | | |
9 | | #include <clientversion.h> |
10 | | #include <tinyformat.h> |
11 | | |
12 | | #include <cstdio> |
13 | | #include <cstdlib> |
14 | | #include <string> |
15 | | #include <string_view> |
16 | | |
17 | | std::string StrFormatInternalBug(std::string_view msg, std::string_view file, int line, std::string_view func) |
18 | 0 | { |
19 | 0 | return strprintf("Internal bug detected: %s\n%s:%d (%s)\n" |
20 | 0 | "%s %s\n" |
21 | 0 | "Please report this issue here: %s\n", |
22 | 0 | msg, file, line, func, CLIENT_NAME, FormatFullVersion(), CLIENT_BUGREPORT); |
23 | 0 | } |
24 | | |
25 | | NonFatalCheckError::NonFatalCheckError(std::string_view msg, std::string_view file, int line, std::string_view func) |
26 | 0 | : std::runtime_error{StrFormatInternalBug(msg, file, line, func)} |
27 | 0 | { |
28 | 0 | } |
29 | | |
30 | | void assertion_fail(std::string_view file, int line, std::string_view func, std::string_view assertion) |
31 | 0 | { |
32 | 0 | auto str = strprintf("%s:%s %s: Assertion `%s' failed.\n", file, line, func, assertion); |
33 | 0 | fwrite(str.data(), 1, str.size(), stderr); |
34 | 0 | std::abort(); |
35 | 0 | } |