00001
00034 #include "exceptionhandler.h"
00035
00036 #include <cxxabi.h>
00037 #include <iostream>
00038
00039 using namespace AlarmNotifications;
00040
00041 void AlarmNotifications::ExceptionHandler ( std::exception& e, std::string location, const bool quit ) noexcept
00042 {
00043 int status = 1;
00044 char*const extype = abi::__cxa_demangle ( typeid ( e ).name(), nullptr, nullptr, &status );
00045 if ( status == 0 )
00046 {
00047 std::cerr << "An exception of type " << extype << " occured while " << location << std::endl;
00048 }
00049 else
00050 {
00051 std::cerr << "An exception of (mangled) type " << typeid ( e ).name() << " occured while instanciating EpicsAccessManager." << std::endl;
00052 }
00053 std::cerr << "Error Message: " << e.what() << std::endl;
00054 free ( extype );
00055 if ( quit )
00056 {
00057 std::cerr << "Exiting gracefully..." << std::endl;
00058 exit ( 1 );
00059 }
00060 else
00061 {
00062 std::cerr << "Dazzled and confused, but trying to continue..." << std::endl;
00063 }
00064 }
00065
00066 void AlarmNotifications::ExceptionHandler ( std::string location, const bool quit ) noexcept
00067 {
00068 std::cerr << "An unknown exception occured while " << location << std::endl;
00069 if ( quit )
00070 {
00071 std::cerr << "Exiting gracefully..." << std::endl;
00072 exit ( 1 );
00073 }
00074 else
00075 {
00076 std::cerr << "Dazzled and confused, but trying to continue..." << std::endl;
00077 }
00078 }