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 156 2007-11-26 20:26:57Z 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 {
00037   
00041 
00043   #define gzthrow(msg) throw gazebo::GazeboError(__FILE__,__LINE__,msg)
00044   
00047 
00059   class GazeboError
00060   {
00062     public: GazeboError();
00063   
00068     public: GazeboError(const char *file, 
00069                         int line, 
00070                         std::string msg);
00071   
00073     public: virtual ~GazeboError();
00074   
00077     public: std::string GetErrorFile() const;
00078   
00081     public: int GetErrorLine() const;
00082   
00083   
00086     public: std::string GetErrorStr() const; 
00087   
00089     private: std::string file;
00090   
00092     private: int line;
00093   
00095     private: std::string str;
00096   
00098     public: friend std::ostream &operator<<(std::ostream& out, const gazebo::GazeboError &err)
00099             {
00100               return out << err.GetErrorFile()
00101                 << ":" << err.GetErrorLine() 
00102                 << " : " << err.GetErrorStr();
00103             }
00104   };
00105   
00107 
00108 }
00109 
00110 #endif

Last updated Aug 04 2007