Bug fix: check if vm exists
[avr-sim.git] / Exception.h
blobfb18035fb916815c969416e29b62ff4dcae3595c
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 \class Exception
13 \author Tom Haber
14 $Author: thaber $
15 $Revision: 1602 $
16 $Date: 2007-03-23 11:31:02 +0100 (Fri, 23 Mar 2007) $
18 The class Exception and its subclasses indicate conditions
19 that a reasonable application might want to catch.
21 class LowLevelException {
22 public:
23 LowLevelException();
24 LowLevelException(const LowLevelException & ex);
25 virtual ~LowLevelException();
27 public:
28 const std::string & message() const;
29 void printStackTrace() const;
30 void printStackTrace(std::ostream & str) const;
32 private:
33 void fillInStackTrace();
35 protected:
36 std::string msg;
37 #if ! defined(DISABLESTACKTRACE)
38 void *callersAddr[MAXTRACESIZE];
39 unsigned short trace;
40 #endif
43 class Exception : public LowLevelException {
44 public:
45 Exception() {}
46 Exception(const char * msg) { this->msg = msg; }
47 Exception(const std::string & msg) { this->msg = msg; }
50 /*!
51 Returns the error message string of this exception.
53 inline const std::string & LowLevelException::message() const {
54 return msg;
57 #endif