All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
mbsim_event.h
1 /* Copyright (C) 2004-2009 MBSim Development Team
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Contact: thschindler@users.berlios.de
18  */
19 
20 #ifndef _MBSIM_EVENT_H_
21 #define _MBSIM_EVENT_H_
22 
23 #include <string>
24 #include <exception>
25 #include <xercesc/dom/DOMElement.hpp>
26 #include <mbxmlutilshelper/dom.h>
27 
28 namespace MBSim {
29 
30  class Element;
31 
38  class MBSimError : public std::exception {
39  public:
45  MBSimError(const Element *context, const std::string &mbsim_error_message_) throw();
46 
51  MBSimError(const std::string &mbsim_error_message_) throw();
52 
53  virtual ~MBSimError() throw() {}
54 
55  /* \brief set the context of the error
56  * Use this function to set the context in a catch(...) block if the context is not known
57  * at the original throw statement. */
58  void setContext(const Element *context);
59 
60  const std::string& getErrorMessage() const { return mbsim_error_message; }
61 
62  const std::string& getPath() const { return path; }
63 
64  const std::vector<MBXMLUtils::EmbedDOMLocator>& getLocationStack() const { return locationStack; }
65 
66  virtual const char* what() const throw();
67 
68  private:
72  std::string mbsim_error_message;
73 
74  std::string path;
75 
76  std::vector<MBXMLUtils::EmbedDOMLocator> locationStack;
77 
78  // just a string to store the memory which is returned by the what() function
79  mutable std::string whatMsg;
80  };
81 
82  // Helper to throw a error with this as the context of the error
83  #define THROW_MBSIMERROR(msg) \
84  throw MBSim::MBSimError(this, msg)
85 }
86 
87 #endif /* _MBSIM_EVENT_H */
88 
basic class of MBSim mainly for plotting
Definition: element.h:58
MBSimError(const Element *context, const std::string &mbsim_error_message_)
constructor
Definition: mbsim_event.cc:30
std::string mbsim_error_message
error message
Definition: mbsim_event.h:72
basic error class for mbsim
Definition: mbsim_event.h:38

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML