X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=src%2Ft2n_exception.hxx;h=0440f056a30bcdaadd7819c2b778c9e0fc22954c;hp=9d789b5cfe67ed45c76dc1ac2134155bbb798935;hb=9a5d7790b094439b9a6f16983e20493c0e43ee02;hpb=cc68aabb16ec32278df8b071c4c9efec7e9f0dce diff --git a/src/t2n_exception.hxx b/src/t2n_exception.hxx index 9d789b5..0440f05 100644 --- a/src/t2n_exception.hxx +++ b/src/t2n_exception.hxx @@ -23,12 +23,11 @@ #include #include -#include -// serialization for std::exception namespace boost { namespace serialization { +// make std::exception serializable template void serialize(Archive & ar, std::exception & g, const unsigned int version) { @@ -39,8 +38,10 @@ void serialize(Archive & ar, std::exception & g, const unsigned int version) namespace libt2n { - -/// a generic exception that can be handeled with libt2n +/** @brief a generic exception that can be handeled with libt2n + @note don't derive the exceptions your application generates directly from this one + but use libt2n::t2n_runtime_error for this +*/ class t2n_exception : public std::exception { private: @@ -48,11 +49,7 @@ class t2n_exception : public std::exception friend class boost::serialization::access; template - void serialize(Archive & ar, const unsigned int version) - { - ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(exception); - ar & BOOST_SERIALIZATION_NVP(message); - } + void serialize(Archive & ar, const unsigned int version); public: t2n_exception(const std::string& _message) @@ -73,7 +70,6 @@ class t2n_exception : public std::exception virtual void do_throw() { throw *this; } }; -BOOST_CLASS_EXPORT(t2n_exception) /// a (unspecified) problem with libt2n communication class t2n_communication_error : public t2n_exception @@ -81,10 +77,7 @@ class t2n_communication_error : public t2n_exception private: friend class boost::serialization::access; template - void serialize(Archive & ar, const unsigned int version) - { - ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(t2n_exception); - } + void serialize(Archive & ar, const unsigned int version); public: t2n_communication_error(const std::string& _message) @@ -100,7 +93,6 @@ class t2n_communication_error : public t2n_exception void do_throw() { throw *this; } }; -BOOST_CLASS_EXPORT(t2n_communication_error) /// can't connect to libt2n server class t2n_connect_error : public t2n_communication_error @@ -108,10 +100,7 @@ class t2n_connect_error : public t2n_communication_error private: friend class boost::serialization::access; template - void serialize(Archive & ar, const unsigned int version) - { - ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(t2n_communication_error); - } + void serialize(Archive & ar, const unsigned int version); public: t2n_connect_error(const std::string& _message) @@ -127,7 +116,6 @@ class t2n_connect_error : public t2n_communication_error void do_throw() { throw *this; } }; -BOOST_CLASS_EXPORT(t2n_connect_error) /// error establishing a socket on the server (only thrown on the server-side) class t2n_server_error : public t2n_communication_error @@ -135,10 +123,7 @@ class t2n_server_error : public t2n_communication_error private: friend class boost::serialization::access; template - void serialize(Archive & ar, const unsigned int version) - { - ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(t2n_communication_error); - } + void serialize(Archive & ar, const unsigned int version); public: t2n_server_error(const std::string& _message) @@ -154,7 +139,6 @@ class t2n_server_error : public t2n_communication_error void do_throw() { throw *this; } }; -BOOST_CLASS_EXPORT(t2n_server_error) /// error transmitting or receiving libt2n messages class t2n_transfer_error : public t2n_communication_error @@ -162,10 +146,7 @@ class t2n_transfer_error : public t2n_communication_error private: friend class boost::serialization::access; template - void serialize(Archive & ar, const unsigned int version) - { - ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(t2n_communication_error); - } + void serialize(Archive & ar, const unsigned int version); public: t2n_transfer_error(const std::string& _message) @@ -181,7 +162,6 @@ class t2n_transfer_error : public t2n_communication_error void do_throw() { throw *this; } }; -BOOST_CLASS_EXPORT(t2n_transfer_error) /// tried to talk to an incompatible libt2n version class t2n_version_mismatch : public t2n_communication_error @@ -189,10 +169,7 @@ class t2n_version_mismatch : public t2n_communication_error private: friend class boost::serialization::access; template - void serialize(Archive & ar, const unsigned int version) - { - ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(t2n_communication_error); - } + void serialize(Archive & ar, const unsigned int version); public: t2n_version_mismatch(const std::string& _message) @@ -208,7 +185,6 @@ class t2n_version_mismatch : public t2n_communication_error void do_throw() { throw *this; } }; -BOOST_CLASS_EXPORT(t2n_version_mismatch) /// illegal libt2n command received class t2n_command_error : public t2n_exception @@ -216,10 +192,7 @@ class t2n_command_error : public t2n_exception private: friend class boost::serialization::access; template - void serialize(Archive & ar, const unsigned int version) - { - ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(t2n_exception); - } + void serialize(Archive & ar, const unsigned int version); public: t2n_command_error(const std::string& _message) @@ -235,7 +208,6 @@ class t2n_command_error : public t2n_exception void do_throw() { throw *this; } }; -BOOST_CLASS_EXPORT(t2n_command_error) /// error serializing or deserializing a libt2n command packet class t2n_serialization_error : public t2n_exception @@ -243,10 +215,7 @@ class t2n_serialization_error : public t2n_exception private: friend class boost::serialization::access; template - void serialize(Archive & ar, const unsigned int version) - { - ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(t2n_exception); - } + void serialize(Archive & ar, const unsigned int version); public: t2n_serialization_error(const std::string& _message) @@ -262,20 +231,18 @@ class t2n_serialization_error : public t2n_exception void do_throw() { throw *this; } }; -BOOST_CLASS_EXPORT(t2n_serialization_error) /** @brief a runtime error within the remote function. derive your own custom exceptions from this one + + @note you must override the virtual clone method if you do so (used by libt2n::command_server::handle()) */ class t2n_runtime_error : public t2n_exception { private: friend class boost::serialization::access; template - void serialize(Archive & ar, const unsigned int version) - { - ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(t2n_exception); - } + void serialize(Archive & ar, const unsigned int version); public: t2n_runtime_error(const std::string& _message) @@ -291,8 +258,9 @@ class t2n_runtime_error : public t2n_exception void do_throw() { throw *this; } }; -BOOST_CLASS_EXPORT(t2n_runtime_error) -} +} // namespace libt2n + +#include "t2n_exception.tcc" #endif