MACE
1.0.0
|
00001 #ifndef MACE_RPC_ERROR_HPP 00002 #define MACE_RPC_ERROR_HPP 00003 #include <boost/exception/all.hpp> 00004 #include <boost/format.hpp> 00005 00006 namespace mace { namespace rpc { 00007 typedef boost::error_info<struct err_msg_,std::string> err_msg; 00008 00009 struct exception : public virtual boost::exception, public virtual std::exception { 00010 const char* what()const throw() { return "exception"; } 00011 virtual void rethrow()const { BOOST_THROW_EXCEPTION(*this); } 00012 const std::string& message()const { return *boost::get_error_info<mace::rpc::err_msg>(*this); } 00013 }; 00014 00015 } } // mace::rpc 00016 00020 #define MACE_RPC_THROW( MSG, ... ) \ 00021 do { \ 00022 BOOST_THROW_EXCEPTION( mace::rpc::exception() << mace::rpc::err_msg( (boost::format( MSG ) __VA_ARGS__ ).str() ) );\ 00023 } while(0) 00024 00025 #endif