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 : 17 7 : std::string StrFormatInternalBug(const char* msg, const char* file, int line, const char* func) 18 : { 19 7 : return strprintf("Internal bug detected: %s\n%s:%d (%s)\n" 20 : "%s %s\n" 21 : "Please report this issue here: %s\n", 22 7 : msg, file, line, func, PACKAGE_NAME, FormatFullVersion(), PACKAGE_BUGREPORT); 23 0 : } 24 : 25 0 : NonFatalCheckError::NonFatalCheckError(const char* msg, const char* file, int line, const char* func) 26 0 : : std::runtime_error{StrFormatInternalBug(msg, file, line, func)} 27 0 : { 28 0 : } 29 : 30 0 : void assertion_fail(const char* file, int line, const char* func, const char* assertion) 31 : { 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 : }