22 #include <boost/exception/diagnostic_information.hpp> 26 this->
frames_to_cut_ = {
"boost",
"exception_detail",
"throw_exception"};
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;
const char * what() const
ExceptionBase()
Default constructor, just calls fill_stacktrace().
void print(std::ostream &out, std::vector< std::string > frames_to_cut=std::vector< std::string >()) const
Prints formated stacktrace into given stream out.
StackTrace stack_trace_
Stacktrace of exception.
std::vector< std::string > frames_to_cut_
Stacktrace frames, which will be cut, see StackTrace::print method.
virtual std::ostringstream & form_message(std::ostringstream &) const
virtual std::string what_type_msg() const
Return type of message ("Program error" for this class). Can be override in descendants.
virtual void print_info(std::ostringstream &out) const =0
virtual ~ExceptionBase()
Destructor, possibly free stacktrace.
Base of exceptions used in Flow123d.
void print_stacktrace(std::ostream &out) const
Prints formated stacktrace into given stream out.