Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
util
exception.cpp
Go to the documentation of this file.
1
// Copyright (c) 2009-2010 Satoshi Nakamoto
2
// Copyright (c) 2009-present The Bitcoin Core developers
3
// Distributed under the MIT software license, see the accompanying
4
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6
#include <
util/exception.h
>
7
8
#include <
tinyformat.h
>
9
#include <
util/log.h
>
10
11
#include <exception>
12
#include <iostream>
13
#include <string>
14
#include <typeinfo>
15
16
#ifdef WIN32
17
#include <windows.h>
18
#endif
// WIN32
19
20
static
std::string
FormatException
(
const
std::exception* pex, std::string_view thread_name)
21
{
22
#ifdef WIN32
23
char
pszModule[
MAX_PATH
] =
""
;
24
GetModuleFileNameA(
nullptr
, pszModule,
sizeof
(pszModule));
25
#else
26
const
char
* pszModule =
"bitcoin"
;
27
#endif
28
if
(pex)
29
return
strprintf
(
30
"EXCEPTION: %s \n%s \n%s in %s \n"
,
typeid
(*pex).name(), pex->what(), pszModule, thread_name);
31
else
32
return
strprintf
(
33
"UNKNOWN EXCEPTION \n%s in %s \n"
, pszModule, thread_name);
34
}
35
36
void
PrintExceptionContinue
(
const
std::exception* pex, std::string_view thread_name)
37
{
38
std::string message =
FormatException
(pex, thread_name);
39
LogWarning
(
"\n\n************************\n%s"
, message);
40
tfm::format
(std::cerr,
"\n\n************************\n%s\n"
, message);
41
}
MAX_PATH
#define MAX_PATH
Definition
compat.h:81
FormatException
static std::string FormatException(const std::exception *pex, std::string_view thread_name)
Definition
exception.cpp:20
PrintExceptionContinue
void PrintExceptionContinue(const std::exception *pex, std::string_view thread_name)
Definition
exception.cpp:36
log.h
LogWarning
#define LogWarning(...)
Definition
log.h:96
tinyformat::format
void format(std::ostream &out, FormatStringCheck< sizeof...(Args)> fmt, const Args &... args)
Format list of arguments to the stream according to given format string.
Definition
tinyformat.h:1079
tinyformat.h
strprintf
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition
tinyformat.h:1172
exception.h
Generated on
for Bitcoin Core by
1.17.0