00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef Exception_h
00022 #define Exception_h
00023
00024 #include <iosfwd>
00025 #include <stdexcept>
00026
00027 #include <y2util/SourceCodeLocation.h>
00028
00030
00031
00038 class Exception : public std::exception
00039 {
00043 friend std::ostream &
00044 operator<<( std::ostream & str, const Exception & obj_r )
00045 { return obj_r.dumpOn( str ); }
00046
00047 public:
00048
00049 typedef SourceCodeLocation location_type;
00050
00054 explicit
00055 Exception( const std::string & msg_r ) throw();
00056
00057 virtual
00058 ~Exception() throw();
00059
00064 virtual const char *
00065 what() const throw();
00066
00070 const location_type &
00071 where() const throw();
00072
00076 void setLocation( const location_type & loc_r ) const throw()
00077 { _loc = loc_r; }
00078
00082 virtual std::ostream &
00083 dumpOn( std::ostream & str ) const;
00084
00085 private:
00086
00087 std::string _msg;
00088 mutable location_type _loc;
00089 };
00091
00092 #define THROW(_Ex) Throw( _Ex, SOURCECODELOCATION )
00093
00094 template<typename _Ex>
00095 inline void Throw( const _Ex & exception_r, const Exception::location_type & loc_r )
00096 { exception_r.setLocation( loc_r ); throw exception_r; }
00097
00099
00100 #endif // Exception_h