51# ifdef HAVE_EXECINFO_H
57#ifndef DOXYGEN_SHOULD_SKIP_THIS
60 std::string _createMsg_(std::string_view filename,
61 std::string_view function,
63 std::string_view msg) {
65 return std::format(
"\n{}\n", msg);
67 return std::format(
"\n{}:{} in {}()\n--------------\n! {}\n--------------\n",
76 std::exception(e), msg_(e.msg_), type_(e.type_), what_(e.what_) {}
78 Exception::Exception(std::string_view aMsg, std::string_view aType) :
79 std::exception(), msg_(aMsg), type_(aType) {
81 what_ =
"[pyAgrum] " + type_ +
": " + msg_;
83 what_ = type_ +
": " + msg_;
87# ifdef HAVE_EXECINFO_H
88# define callStackDepth 20
89 void* array[callStackDepth];
92 size = backtrace(array, callStackDepth);
93 strings = backtrace_symbols(array, size);
95 std::string callstack_str;
97 for (
size_t i = 1; i < size; ++i) {
98 callstack_str += std::format(
"{} :{}\n", i, strings[i]);
102 callstack_ = callstack_str;
104 callstack_ =
"Callstack only in linux debug mode when execinfo.h available";
107 callstack_ =
"Callstack only in linux debug mod ewhen execinfo.h available";
Base class for all aGrUM's exceptions.
Exception(std::string_view aMsg="", std::string_view aType="Generic error")
gum is the global namespace for all aGrUM entities