Gazebo

GazeboError.hh

00001 /*
00002  *  Gazebo - Outdoor Multi-Robot Simulator
00003  *  Copyright (C) 2003  
00004  *     Nate Koenig & Andrew Howard
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 /*
00022  * Desc: Gazebo Error
00023  * Author: Nathan Koenig
00024  * Date: 07 May 2007
00025  * SVN info: $Id: GazeboError.hh 6394 2008-05-02 14:32:17Z natepak $
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

Last updated Aug 04 2007