22 #include <boost/exception/diagnostic_information.hpp>
26 this->
frames_to_cut_ = {
"boost",
"exception_detail",
"throw_exception"};
32 : stack_trace_(other.stack_trace_), frames_to_cut_(other.frames_to_cut_) {}
50 static std::string message(1024,
' ');
54 std::ostringstream converter;
56 if (EI_NestedMessage::ptr(*
this)) {
57 converter <<
"--------------------------------------------------------" << std::endl;
58 converter <<
"Nested exception:" << *(EI_NestedMessage::ptr(*
this)) << std::endl;
60 if (EI_Nested::ptr(*
this)) {
61 std::shared_ptr<ExceptionBase> exc_ptr = *EI_Nested::ptr(*
this);
63 converter <<
"--------------------------------------------------------" << std::endl;
64 converter <<
"Nested exception:" << std::endl;
65 exc_ptr->form_message(converter);
66 if (EI_NestedMessage::ptr(*exc_ptr)) {
67 converter <<
"--------------------------------------------------------" << std::endl;
68 converter <<
"Nested exception:" << *(EI_NestedMessage::ptr(*exc_ptr)) << std::endl;
71 if (EI_Nested::ptr(*exc_ptr)) {
72 exc_ptr = *EI_Nested::ptr(*exc_ptr);
78 message = converter.str();
79 return message.c_str();
81 }
catch (std::exception &exc) {
82 std::cerr <<
"*** Exception encountered in exception handling routines ***" << std::endl <<
"*** Message is " << std::endl
83 << exc.what() << std::endl <<
"*** Aborting! ***" << std::endl;
87 std::cerr <<
"*** Exception encountered in exception handling routines ***" << std::endl <<
"*** Aborting! ***"
97 return "Program Error: ";
103 converter <<
"--------------------------------------------------------" << std::endl;
107 converter <<
"\n** Diagnosting info **\n" ;
108 converter << boost::diagnostic_information_what( *
this );
110 converter << std::endl <<
"--------------------------------------------------------" << std::endl;
Base of exceptions used in Flow123d.
virtual std::string what_type_msg() const
Return type of message ("Program error" for this class). Can be override in descendants.
virtual ~ExceptionBase()
Destructor, possibly free stacktrace.
void print_stacktrace(std::ostream &out) const
Prints formated stacktrace into given stream out.
virtual std::ostringstream & form_message(std::ostringstream &) const
const char * what() const
ExceptionBase()
Default constructor, just calls fill_stacktrace().
StackTrace stack_trace_
Stacktrace of exception.
virtual void print_info(std::ostringstream &out) const =0
std::vector< std::string > frames_to_cut_
Stacktrace frames, which will be cut, see StackTrace::print method.
void print(std::ostream &out, std::vector< std::string > frames_to_cut=std::vector< std::string >()) const
Prints formated stacktrace into given stream out.