17 #ifndef KAAEXCEPTION_HPP_
18 #define KAAEXCEPTION_HPP_
20 #include <boost/format.hpp>
26 #define WIN32_LEAN_AND_MEAN
31 #undef WIN32_LEAN_AND_MEAN
45 ss <<
"[Kaa OpenSource Project] Instruction failed! Details: \"" << f
46 <<
"\" Original message: " << std::exception::what();
53 ss <<
"[Kaa OpenSource Project] Instruction failed! Details: \"" << message
54 <<
"\" Original message: " << std::exception::what();
61 ss <<
"[Kaa OpenSource Project] Instruction failed! Details: \"" << e.what();
66 virtual const char *
what()
const throw() {
67 return message_.c_str();
75 void captureStack(std::stringstream& ss) {
78 int i, trace_size = 0;
82 process = GetCurrentProcess();
83 SymInitialize( process, NULL, TRUE );
84 trace_size = CaptureStackBackTrace( 0, 16, trace, NULL );
85 symbol = ( SYMBOL_INFO * )calloc(
sizeof( SYMBOL_INFO ) + 256 *
sizeof( char ), 1 );
86 symbol->MaxNameLen = 255;
87 symbol->SizeOfStruct =
sizeof( SYMBOL_INFO );
89 char **messages = (
char **)
nullptr;
90 trace_size = backtrace(trace, 16);
91 messages = backtrace_symbols(trace, trace_size);
93 ss << std::endl <<
"Backtrace: " << std::endl;
94 for (i = 0; i < trace_size; ++i) {
96 SymFromAddr( process, ( DWORD64 )( trace[ i ] ), 0, symbol );
97 ss <<
"[" << trace_size - i - 1 <<
"] " << symbol->Name <<
" - " << boost::format(
"0x%0X")%symbol->Address << std::endl;
99 ss <<
"[" << i <<
"] " << messages[i] << std::endl;
106 static_cast<void>(ss);
KaaException(const std::string &message)
virtual const char * what() const
KaaException(const std::exception &e)
KaaException(boost::format &f)
virtual ~KaaException() noexcept=default