17 #ifndef KAAEXCEPTION_HPP_
18 #define KAAEXCEPTION_HPP_
20 #include <boost/format.hpp>
25 #define WIN32_LEAN_AND_MEAN
30 #undef WIN32_LEAN_AND_MEAN
43 ss <<
"[Kaa OpenSource Project] Instruction failed! Details: \"" << f
44 <<
"\" Original message: " << std::exception::what();
51 ss <<
"[Kaa OpenSource Project] Instruction failed! Details: \"" << message
52 <<
"\" Original message: " << std::exception::what();
59 ss <<
"[Kaa OpenSource Project] Instruction failed! Details: \"" << e.what();
64 virtual const char *
what()
const throw() {
65 return message_.c_str();
73 void captureStack(std::stringstream& ss) {
75 int i, trace_size = 0;
79 process = GetCurrentProcess();
80 SymInitialize( process, NULL, TRUE );
81 trace_size = CaptureStackBackTrace( 0, 16, trace, NULL );
82 symbol = ( SYMBOL_INFO * )calloc(
sizeof( SYMBOL_INFO ) + 256 *
sizeof( char ), 1 );
83 symbol->MaxNameLen = 255;
84 symbol->SizeOfStruct =
sizeof( SYMBOL_INFO );
86 char **messages = (
char **)
nullptr;
87 trace_size = backtrace(trace, 16);
88 messages = backtrace_symbols(trace, trace_size);
90 ss << std::endl <<
"Backtrace: " << std::endl;
91 for (i = 0; i < trace_size; ++i) {
93 SymFromAddr( process, ( DWORD64 )( trace[ i ] ), 0, symbol );
94 ss <<
"[" << trace_size - i - 1 <<
"] " << symbol->Name <<
" - " << boost::format(
"0x%0X")%symbol->Address << std::endl;
96 ss <<
"[" << i <<
"] " << messages[i] << std::endl;
KaaException(const std::string &message)
virtual const char * what() const
KaaException(const std::exception &e)
KaaException(boost::format &f)
virtual ~KaaException()=default