Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

Exception.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                               core system                            |
00010 |                                         (C) SuSE Linux Products GmbH |
00011 \----------------------------------------------------------------------/
00012 
00013   File:       Exception.h
00014 
00015   Author:     Michael Andres <ma@suse.de>
00016   Maintainer: Michael Andres <ma@suse.de>
00017 
00018   Purpose:
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 //      CLASS NAME : Exception
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

Generated on Fri Feb 24 00:30:02 2006 for liby2util by  doxygen 1.4.4