Fixed problem in DeviceSettings::strParam, returned wrong string
[avr-sim.git] / src / Exception.h
blobbf5aa0a1d6b05a732f893a6d4bc29e0e74811574
1 #ifndef UTIL_EXCEPTION_H
2 #define UTIL_EXCEPTION_H
4 #include <string>
6 #ifndef MAXTRACESIZE
7 # define MAXTRACESIZE 20
8 #endif
10 namespace util {
11 /*!
12 \author Tom Haber
13 $Author: thaber $
14 $Revision: 1602 $
15 $Date: 2007-03-23 11:31:02 +0100 (Fri, 23 Mar 2007) $
16 \brief General Exception class
18 The class LowLevelException and its subclasses indicate
19 conditions that a reasonable application might want to catch.
21 Direct subclasses of LowLevelException (instead of Exception)
22 indicate severe error conditions such as segmentation violations,
23 bad memory accesses, ... It makes sense to only catch LowLevelException
24 in the main() and catch Exception elsewhere.
26 Don't forget to specify -rdynamic for stacktraces in linux
27 In windows you need a program database
29 class LowLevelException {
30 public:
31 LowLevelException();
32 LowLevelException(const LowLevelException & ex);
33 virtual ~LowLevelException();
35 public:
36 const std::string & message() const;
37 void printStackTrace() const;
38 void printStackTrace(std::ostream & str) const;
40 private:
41 void fillInStackTrace();
43 protected:
44 std::string msg;
45 #if ! defined(DISABLESTACKTRACE)
46 void *callersAddr[MAXTRACESIZE];
47 unsigned short trace;
48 #endif
51 /*!
52 \author Tom Haber
53 $Author: thaber $
54 $Revision: 1602 $
55 $Date: 2007-03-23 11:31:02 +0100 (Fri, 23 Mar 2007) $
56 \brief General Exception class
58 The class Exception and its subclasses indicate conditions
59 that a reasonable application might want to catch.
61 Direct subclasses of LowLevelException (instead of Exception)
62 indicate severe error conditions such as segmentation violations,
63 bad memory accesses, ... It makes sense to only catch LowLevelException
64 in the main() and catch Exception elsewhere.
66 class Exception : public LowLevelException {
67 public:
68 Exception() {}
69 Exception(const char * msg) { this->msg = msg; }
70 Exception(const std::string & msg) { this->msg = msg; }
73 /*!
74 Returns the error message string of this exception.
76 inline const std::string & LowLevelException::message() const {
77 return msg;
80 #endif