28 #include <agrum/agrum.h> 29 #include <agrum/tools/core/exceptions.h> 31 # ifdef HAVE_EXECINFO_H 32 # include <execinfo.h> 37 #ifndef DOXYGEN_SHOULD_SKIP_THIS 40 const std::string _createMsg_(
const std::string& filename,
41 const std::string& function,
43 const std::string& msg) {
44 std::stringstream stream;
46 stream << std::endl << msg << std::endl;
49 <<
"<" << filename <<
"> " << function <<
"() #" << std::setw(6) << std::dec << line
51 <<
"--------------" << std::endl
52 <<
"! " << msg << std::endl
53 <<
"--------------" << std::endl;
57 Exception::Exception(
const Exception& e) : msg_(e.msg_), type_(e.type_) {}
59 Exception::Exception(std::string aMsg, std::string aType) :
60 msg_(std::move(aMsg)), type_(std::move(aType)) {
61 # ifdef GUM_DEBUG_MODE 62 # ifdef HAVE_EXECINFO_H 63 # define callStackDepth 20
64 void* array[callStackDepth];
67 size = backtrace(array, callStackDepth);
68 strings = backtrace_symbols(array, size);
70 std::stringstream stream;
72 for (size_t i = 1; i < size; ++i) {
73 stream << i <<
" :" << strings[i] << std::endl;
77 callstack_ = stream.str();
79 callstack_ =
"Callstack only in linux debug mode when execinfo.h available";
82 callstack_ =
"Callstack only in linux debug mod ewhen execinfo.h available";