GazeboError.hh
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef GAZEBOERROR_HH
00029 #define GAZEBOERROR_HH
00030
00031 #include <iostream>
00032 #include <sstream>
00033 #include <string>
00034
00035 namespace gazebo
00036 {
00040
00042 #define gzthrow(msg) {std::ostringstream throwStream; throwStream << "Exception: " << msg << std::endl << std::flush; throw gazebo::GazeboError(__FILE__,__LINE__,throwStream.str()); }
00043
00044
00047
00063 class GazeboError
00064 {
00066 public: GazeboError();
00067
00072 public: GazeboError(const char *file,
00073 int line,
00074 std::string msg);
00075
00077 public: virtual ~GazeboError();
00078
00081 public: std::string GetErrorFile() const;
00082
00085 public: int GetErrorLine() const;
00086
00087
00090 public: std::string GetErrorStr() const;
00091
00093 private: std::string file;
00094
00096 private: int line;
00097
00099 private: std::string str;
00100
00102 public: friend std::ostream &operator<<(std::ostream& out, const gazebo::GazeboError &err)
00103 {
00104 return out << err.GetErrorFile()
00105 << ":" << err.GetErrorLine()
00106 << " : " << err.GetErrorStr();
00107 }
00108 };
00109
00111
00112 }
00113
00114 #endif