Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

exception.hpp

Go to the documentation of this file.
00001 #ifndef s11n_net_s11n_v1_1_EXCEPTION_HPP_INCLUDED
00002 #define s11n_net_s11n_v1_1_EXCEPTION_HPP_INCLUDED 1
00003 
00004 #include <string>
00005 #include <exception>
00006 
00007 namespace s11n {
00008 
00009 
00010     /**
00011        The base-most exception type used by s11n.
00012     */
00013         struct s11n_exception : public std::exception
00014         {
00015     public:
00016         virtual ~s11n_exception() throw() {}
00017                 explicit s11n_exception( const std::string & What );
00018         /**
00019            Creates an error string consisting of:
00020 
00021            file:linenum: What
00022         */
00023                 s11n_exception( const std::string & What, const std::string & file, unsigned int linenum );
00024                 virtual const char * what() const throw();
00025         private:
00026                 std::string m_what;
00027         };
00028 
00029     /**
00030        An exception type for classloader-related exceptions. These
00031        need to be caught separately from s11n_exceptions in some
00032        cases because sometimes a classloader can try other
00033        alternatives on an error.
00034     */
00035     struct factory_exception : public s11n_exception
00036     {
00037     public:
00038         virtual ~factory_exception() throw() {}
00039         explicit factory_exception( const std::string & What ) : s11n_exception( What ) {}
00040                 factory_exception( const std::string & What, const std::string & file, unsigned int line ) : s11n_exception( What,file,line ) {}
00041     };
00042 
00043 
00044     /**
00045        Really for use by clients, i/o layers, and s11nlite, not by
00046        the s11n core.
00047     */
00048     struct io_exception : public s11n_exception
00049     {
00050     public:
00051         virtual ~io_exception() throw() {}
00052         explicit io_exception( const std::string & What ) : s11n_exception( What ) {}
00053                 io_exception( const std::string & What, const std::string & file, unsigned int line ) : s11n_exception( What,file,line ) {}
00054     };
00055 
00056 
00057 } // namespace s11n
00058 
00059 /**
00060    S11N_THROW(WHAT) simply throws s11n_exception(WHAT,__FILE__,__LINE__).
00061 */
00062 #define S11N_THROW(WHAT) throw ::s11n::s11n_exception(WHAT,__FILE__,__LINE__)
00063 
00064 #endif // s11n_net_s11n_v1_1_EXCEPTION_HPP_INCLUDED

Generated on Sun Dec 25 20:26:11 2005 for libs11n-1.2.3 by  doxygen 1.4.4