MIDAS
Loading...
Searching...
No Matches
mexception Class Reference

#include <mexcept.h>

Inheritance diagram for mexception:
Collaboration diagram for mexception:

Public Member Functions

 mexception (const std::string &arg, bool stack_trace, const char *file, int line)
 
 ~mexception () throw ()
 
const charwhat () const throw ()
 
 mexception (const mexception &ex) noexcept
 

Private Attributes

std::string msg
 

Friends

std::ostream & operator<< (std::ostream &output, mexception &m)
 

Detailed Description

Definition at line 32 of file mexcept.h.

Constructor & Destructor Documentation

◆ mexception() [1/2]

mexception::mexception ( const std::string &  arg,
bool  stack_trace,
const char file,
int  line 
)
inline

Definition at line 35 of file mexcept.h.

35 :
36 std::runtime_error(arg) {
37 std::stringstream trace_buf;
38 if (file[0])
39 trace_buf << file << ":" << line << ": " << arg;
40 else
41 trace_buf << arg;
42
43 if (stack_trace) {
44 // create strack trace and add it to message
45 trace_buf << std::endl << "Stack trace:" << std::endl;
46 void *callstack[128];
47 char buf[1024];
48 int n = backtrace(callstack, sizeof(callstack) / sizeof(callstack[0]));
50 for (int i = 1; i < n; i++) {
52 if (dladdr(callstack[i], &info)) {
53 char *demangled = nullptr;
54 int status = 0;
55 demangled = abi::__cxa_demangle(info.dli_sname, nullptr, 0, &status);
56 snprintf(buf, sizeof(buf), "%-3d 0x%018lX %s + %zd\n",
57 i, (long unsigned int) callstack[i],
59 (char *) callstack[i] - (char *) info.dli_saddr);
60 free(demangled);
61 } else {
62 snprintf(buf, sizeof(buf), "%-3d 0x%018lX\n",
63 i, (long unsigned int) callstack[i]);
64 }
65 trace_buf << buf;
66 }
67 free(symbols);
68 }
69
70 msg = trace_buf.str();
71 }
std::string msg
Definition mexcept.h:33
void ** info
Definition fesimdaq.cxx:41
DWORD n[4]
Definition mana.cxx:247
INT i
Definition mdump.cxx:32
DWORD status
Definition odbhist.cxx:39
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
Here is the call graph for this function:

◆ ~mexception()

mexception::~mexception ( )
throw (
)
inline

Definition at line 73 of file mexcept.h.

73{}

◆ mexception() [2/2]

mexception::mexception ( const mexception ex)
inlinenoexcept

Definition at line 84 of file mexcept.h.

84: std::runtime_error(ex.msg),msg(ex.msg) {};

Member Function Documentation

◆ what()

const char * mexception::what ( ) const
throw (
)
inline

Definition at line 75 of file mexcept.h.

75 {
76 return msg.c_str();
77 }

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  output,
mexception m 
)
friend

Definition at line 79 of file mexcept.h.

79 {
80 output << m.what();
81 return output;
82 };
const char * what() const
Definition mexcept.h:75
static void output(code_int code)
Definition mgd.cxx:1647

Member Data Documentation

◆ msg

std::string mexception::msg
private

Definition at line 33 of file mexcept.h.


The documentation for this class was generated from the following file: