AlarmNotifications
PANDA Slow Control Alarm Daemon
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
exceptionhandler.cpp
Go to the documentation of this file.
1 
34 #include "exceptionhandler.h"
35 
36 #include <cxxabi.h>
37 #include <iostream>
38 
39 using namespace AlarmNotifications;
40 
41 void AlarmNotifications::ExceptionHandler ( std::exception& e, std::string location, const bool quit ) noexcept
42 {
43  int status = 1; // 1 doesn't exist as return value of __cxa_demangle(), so if status is not 0 afterwards something went wrong
44  char*const extype = abi::__cxa_demangle ( typeid ( e ).name(), nullptr, nullptr, &status );
45  if ( status == 0 )
46  {
47  std::cerr << "An exception of type " << extype << " occured while " << location << std::endl;
48  }
49  else
50  {
51  std::cerr << "An exception of (mangled) type " << typeid ( e ).name() << " occured while instanciating EpicsAccessManager." << std::endl;
52  }
53  std::cerr << "Error Message: " << e.what() << std::endl;
54  free ( extype );
55  if ( quit )
56  {
57  std::cerr << "Exiting gracefully..." << std::endl;
58  exit ( 1 );
59  }
60  else
61  {
62  std::cerr << "Dazzled and confused, but trying to continue..." << std::endl;
63  }
64 }
65 
66 void AlarmNotifications::ExceptionHandler ( std::string location, const bool quit ) noexcept
67 {
68  std::cerr << "An unknown exception occured while " << location << std::endl;
69  if ( quit )
70  {
71  std::cerr << "Exiting gracefully..." << std::endl;
72  exit ( 1 );
73  }
74  else
75  {
76  std::cerr << "Dazzled and confused, but trying to continue..." << std::endl;
77  }
78 }
Namespace for Alarm Notifications application.
#define noexcept
Allow using the noexcept keyword with GCC < 4.6.
Definition: oldgcccompat.h:52
void ExceptionHandler(std::exception &e, std::string location, const bool quit=false) noexcept
Generic exception handler for known exceptions.
Generic functions for exception handling.