Line data Source code
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) 8 : #include <config/bitcoin-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 0 : std::string StrFormatInternalBug(std::string_view msg, std::string_view file, int line, std::string_view func) 20 : { 21 0 : return strprintf("Internal bug detected: %s\n%s:%d (%s)\n" 22 : "%s %s\n" 23 : "Please report this issue here: %s\n", 24 0 : msg, file, line, func, PACKAGE_NAME, FormatFullVersion(), PACKAGE_BUGREPORT); 25 0 : } 26 : 27 0 : NonFatalCheckError::NonFatalCheckError(std::string_view msg, std::string_view file, int line, std::string_view func) 28 0 : : std::runtime_error{StrFormatInternalBug(msg, file, line, func)} 29 0 : { 30 0 : } 31 : 32 0 : void assertion_fail(std::string_view file, int line, std::string_view func, std::string_view assertion) 33 : { 34 0 : auto str = strprintf("%s:%s %s: Assertion `%s' failed.\n", file, line, func, assertion); 35 0 : fwrite(str.data(), 1, str.size(), stderr); 36 0 : std::abort(); 37 0 : }