Bytemaster's Boost Libraries
|
00001 #ifndef _BOOST_RPC_ERRORS_HPP_ 00002 #define _BOOST_RPC_ERRORS_HPP_ 00003 #include <boost/exception/all.hpp> 00004 #include <boost/throw_exception.hpp> 00005 00006 namespace boost { namespace rpc { 00007 00008 struct required_field_not_set : public virtual boost::exception, public virtual std::exception 00009 { 00010 const char* what()const throw() { return "required field not set"; } 00011 virtual void rethrow()const { BOOST_THROW_EXCEPTION(*this); } 00012 }; 00013 00014 namespace protocol_buffer { 00015 00016 template<typename T> 00017 void pack( std::vector<char>& msg, const T& v ); 00018 00019 struct key_type_mismatch : public virtual boost::exception, public virtual std::exception 00020 { 00021 key_type_mismatch( const char* name=0):m_name(name){} 00022 const char* name(){ return m_name; } 00023 const char* what()const throw() { return "key/type mismatch"; } 00024 virtual void rethrow()const { BOOST_THROW_EXCEPTION(*this); } 00025 00026 private: 00027 const char* m_name; 00028 }; 00029 struct field_size_larger_than_buffer : public virtual boost::exception, public virtual std::exception 00030 { 00031 field_size_larger_than_buffer( const char* name=0):m_name(name){} 00032 const char* name(){ return m_name; } 00033 const char* what()const throw() { return "field size is larger than buffer"; } 00034 virtual void rethrow()const { BOOST_THROW_EXCEPTION(*this); } 00035 00036 private: 00037 const char* m_name; 00038 }; 00039 struct field_not_found : public virtual boost::exception, public virtual std::exception 00040 { 00041 const char* what()const throw() { return "field not found"; } 00042 virtual void rethrow()const { BOOST_THROW_EXCEPTION(*this); } 00043 }; 00044 } // namespace protocol buffer 00045 00046 } } // boost::rpc 00047 00048 #endif