Warning: include(php/utility.php): Failed to open stream: No such file or directory in /home/argos/argos3/doc/api/embedded/a00463_source.php on line 2

Warning: include(): Failed opening 'php/utility.php' for inclusion (include_path='.:/usr/lib64/php') in /home/argos/argos3/doc/api/embedded/a00463_source.php on line 2
The ARGoS Website

argos_exception.h
Go to the documentation of this file.
1 
43 #ifndef ARGOS_EXCEPTION_H
44 #define ARGOS_EXCEPTION_H
45 
46 namespace argos {
47  class CARGoSException;
48 }
49 
50 #include <stdexcept>
51 #include <sstream>
52 
53 namespace argos {
54 
61  class CARGoSException : public std::exception {
62 
63  public:
64 
70  CARGoSException(const std::string& str_what, std::exception* pc_nested = NULL) throw() :
71  m_strWhat("[FATAL] " + str_what), m_pcNested(pc_nested) {
72  if (m_pcNested != NULL) {
73  std::ostringstream w;
74  w << m_strWhat
75  << std::endl
76  << m_pcNested->what();
77  m_strWhat = w.str();
78  }
79  }
83  virtual ~CARGoSException() throw() {
84  }
85 
90  virtual const char* what() const throw() {
91  return m_strWhat.c_str();
92  }
93 
94  private:
95 
100  std::string m_strWhat;
102  std::exception* m_pcNested;
103 
104  };
105 
106 }
107 
111 #define THROW_ARGOSEXCEPTION(message) { std::ostringstream what; what << message; throw CARGoSException(what.str()); }
112 
115 #define THROW_ARGOSEXCEPTION_NESTED(message, nested) { std::ostringstream what; what << message; throw CARGoSException(what.str(), &nested); }
116 
117 #ifndef NDEBUG
118 
122 #define ARGOS_ASSERT(condition, message) { if ( !(condition) ) THROW_ARGOSEXCEPTION(message); }
123 #else
124 #define ARGOS_ASSERT(condition, message)
125 #endif
126 
127 #endif
virtual const char * what() const
Returns the error message that explains what happened and why the exception was thrown The returned m...
CARGoSException(const std::string &str_what, std::exception *pc_nested=NULL)
Class constructor.
The exception that wraps all errors in ARGoS.
virtual ~CARGoSException()
Class destructor.
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12