ChannelMapExceptionOLD.h
Go to the documentation of this file.
1 #ifndef _CHANNELMAPEXCEPTION_H
2 #define _CHANNELMAPEXCEPTION_H
3 
4 #include <execinfo.h>
5 #include <stdexcept>
6 #include <string>
7 #include <sstream>
8 #include <cstdlib>
9 
10 #define GENERATE_CHANNELMAP_EXCEPTION(msg) \
11  throw daqchannelmap::ChannelMapException(__FILE__, __LINE__, msg)
12 
13 namespace daqchannelmap {
14 
15 /**
16  * Class to report exceptions in the DAQChannel Map package.
17  *
18  * @author A.Norman (based off K.Biery Template)
19  * @version $Revision: 1.1.12.1 $ $Date: 2019/09/27 00:06:47 $
20  */
21 
23 
24  public:
25 
26  /**
27  * Constructs a data format exception instance from the specified
28  * file, line number, and message.
29  */
31  const std::string &message) {
32 
33  // convert the line number to a string
34  std::stringstream tmpStream;
35  tmpStream << line;
36  std::string lineNumber = tmpStream.str();
37 
38  // build up the exception text
39  _fullText = "DAQChannelMap - Error: " + message + " at " + fileName + ":" + lineNumber;
40 
41  // add some limited stack trace information
42  void *array[10];
43  size_t size;
44  char **strings;
45  size_t idx;
46 
47  size = backtrace (array, 10);
48  strings = backtrace_symbols (array, size);
49  tmpStream.seekp(0); // clear out the stream
50  for (idx = 0; idx < size; idx++) {
51  tmpStream << " " << strings[idx] << std::endl;
52  }
53  free (strings);
54 
55  _fullText += "\n Stack trace:\n" + tmpStream.str();
56  }
57 
58  /**
59  * Destructor.
60  */
61  virtual ~ChannelMapException() throw() {
62  return;
63  }
64 
65  /**
66  * Returns a description of the exception.
67  */
68  const char* what() const throw() {
69  return _fullText.c_str();
70  }
71 
72  private:
73 
74  /**
75  * The full description of the exception.
76  */
78 
79 };
80 
81 } // end of namespace
82 
83 #endif
fileName
Definition: plotROC.py:78
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
ChannelMapException(const std::string &fileName, int line, const std::string &message)
enum BeamMode string