CARMA C++
SystemException.h
Go to the documentation of this file.
1 #ifndef CARMA_UTIL_SYSTEM_EXCEPTION_H
2 #define CARMA_UTIL_SYSTEM_EXCEPTION_H
3 
26 #include <string>
27 
28 // show be including <iosfwd> but the API passes std::ostringstream's by value
29 #include <sstream>
30 
31 #include <cerrno>
32 
34 
35 
36 namespace carma {
37 namespace util {
38 
39 
47  public:
48  SystemException( const SystemException & rhs );
49 
77  SystemException( const char * mesg,
78  const char * sysMesg = strerror( errno ),
79  const char * fileName = __FILE__,
80  const int lineNum = __LINE__ );
81 
107  SystemException( std::ostringstream & message,
108  const char * sysMessage = strerror( errno ),
109  const char * fileName = __FILE__,
110  const int lineNum = __LINE__ );
111 
137  SystemException( std::ostringstream & message,
138  const std::ostringstream sysMessage = std::ostringstream( strerror( errno ) ),
139  const char * fileName = __FILE__,
140  const int lineNum = __LINE__ );
141 
167  SystemException( std::string & istring,
168  const std::string sysMessage = strerror( errno ),
169  const char * fileName = __FILE__,
170  const int lineNum = __LINE__ );
171 
175  virtual ~SystemException( ) throw( );
176 
177  SystemException & operator=( const SystemException & rhs );
178 
189  virtual const char * getSysMessage( ) const;
190 
191  virtual ::std::string getLogString( ) const;
192 
193  protected:
194  explicit SystemException( );
195 
196  private:
197  void clearSysMesg( );
198 
199  void setSysMesg( const ::std::string & sysMesg );
200 
201  const char * sysMesg_;
202  bool weAllocatedSysMesg_;
203 }; // class SystemException
204 
205 
206 } // namespace carma::util
207 } // namespace carma
208 
209 
219 #define CARMA_SYSTEM_EXCEPTION(msg) carma::util::SystemException((msg), strerror(errno), __FILE__, __LINE__)
220 
221 
222 #endif // CARMA_UTIL_SYSTEM_EXCEPTION_H
virtual ~SystemException()
Destructor for SystemException.
This is the include file for Carma exception handling utilities.
Exception class for managing system errors.
Base exception class for managing carma errors.
Definition: BaseException.h:48
virtual const char * getSysMessage() const
gets error message set within this instance.