erste version, test vor configure
This commit is contained in:
41
mrw/autostacktracestderr.cpp
Normal file
41
mrw/autostacktracestderr.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include <mrw/stacktrace.hpp>
|
||||
#include <mrw/exception.hpp>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
|
||||
namespace mrw {
|
||||
|
||||
/// @todo integrate it into the distribution and document it
|
||||
void unexpected() {
|
||||
std::cerr<<"UNEXPECTED EXCEPTION: ----------------------------"<<std::endl;
|
||||
try {
|
||||
throw;
|
||||
} catch (const mrw::exception& x) {
|
||||
StackTrace::createSymtable();
|
||||
std::cerr<<"---------- Reason:"<<std::endl
|
||||
<<x.what()<<std::endl
|
||||
<<"---------- Stack:"<<std::endl
|
||||
<<x.stacktrace()<<std::endl;
|
||||
} catch (const std::exception& x) {
|
||||
std::cerr<<"---------- Reason:"<<std::endl
|
||||
<<x.what()<<std::endl
|
||||
<<"---------- Stack: **** not available ****"<<std::endl;
|
||||
} catch (...) {
|
||||
std::cerr<<"---------- Reason: **** not available ****"<<std::endl
|
||||
<<"---------- Stack: **** not available ****"<<std::endl;
|
||||
}
|
||||
std::cerr<<"-------------------------------------------------"<<std::endl;
|
||||
throw std::bad_exception();
|
||||
}
|
||||
|
||||
class AutoStackTrace {
|
||||
public:
|
||||
AutoStackTrace() {
|
||||
std::set_unexpected(&mrw::unexpected);
|
||||
}
|
||||
};
|
||||
|
||||
// initialize stack traces (load symbols)
|
||||
static AutoStackTrace _autoStackTrace;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user