X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=src%2Ft2n_exception.hxx;h=4ce11aa2e209f7eb8c657a13f4e322eebef2d23c;hp=c756b09b86698109e40be40472ea4f5c6770d1bb;hb=e453407db5951aa7f504282ea82d1ca1f19d22fb;hpb=ac7fdc22899c0c493fda5fdb3a4cb67e77504a6b diff --git a/src/t2n_exception.hxx b/src/t2n_exception.hxx index c756b09..4ce11aa 100644 --- a/src/t2n_exception.hxx +++ b/src/t2n_exception.hxx @@ -22,13 +22,12 @@ #include #include -#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,23 +38,18 @@ void serialize(Archive & ar, std::exception & g, const unsigned int version) namespace libt2n { - -// a generic exception that can be handeled with libt2n +/// a generic exception that can be handeled with libt2n class t2n_exception : public std::exception { private: - string message; + std::string message; 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 string& _message) + t2n_exception(const std::string& _message) { message=_message; } t2n_exception() @@ -73,225 +67,193 @@ class t2n_exception : public std::exception virtual void do_throw() { throw *this; } }; -BOOST_CLASS_EXPORT(t2n_exception) -// a (unspecified) problem with libt2n communication +/// a (unspecified) problem with libt2n communication 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 string& _message) + t2n_communication_error(const std::string& _message) : t2n_exception(_message) { } t2n_communication_error() { } - ipc_exception* clone() const + t2n_exception* clone() const { return new t2n_communication_error(*this); } void do_throw() { throw *this; } }; -BOOST_CLASS_EXPORT(t2n_communication_error) -// can't connect to libt2n server +/// can't connect to libt2n server 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 string& _message) + t2n_connect_error(const std::string& _message) : t2n_communication_error(_message) { } t2n_connect_error() { } - ipc_exception* clone() const + t2n_exception* clone() const { return new t2n_connect_error(*this); } void do_throw() { throw *this; } }; -BOOST_CLASS_EXPORT(t2n_connect_error) -// error establishing a socket on the server (only thrown on the server-side) +/// error establishing a socket on the server (only thrown on the server-side) 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 string& _message) + t2n_server_error(const std::string& _message) : t2n_communication_error(_message) { } t2n_server_error() { } - ipc_exception* clone() const + t2n_exception* clone() const { return new t2n_server_error(*this); } void do_throw() { throw *this; } }; -BOOST_CLASS_EXPORT(t2n_server_error) -// error transmitting or receiving libt2n messages +/// error transmitting or receiving libt2n messages 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 string& _message) + t2n_transfer_error(const std::string& _message) : t2n_communication_error(_message) { } t2n_transfer_error() { } - ipc_exception* clone() const + t2n_exception* clone() const { return new t2n_transfer_error(*this); } void do_throw() { throw *this; } }; -BOOST_CLASS_EXPORT(t2n_transfer_error) -// tried to talk to an incompatible libt2n version +/// tried to talk to an incompatible libt2n version 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 string& _message) + t2n_version_mismatch(const std::string& _message) : t2n_communication_error(_message) { } t2n_version_mismatch() { } - ipc_exception* clone() const + t2n_exception* clone() const { return new t2n_version_mismatch(*this); } void do_throw() { throw *this; } }; -BOOST_CLASS_EXPORT(t2n_version_mismatch) -// illegal libt2n command received +/// illegal libt2n command received 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 string& _message) + t2n_command_error(const std::string& _message) : t2n_exception(_message) { } t2n_command_error() { } - ipc_exception* clone() const + t2n_exception* clone() const { return new t2n_command_error(*this); } void do_throw() { throw *this; } }; -BOOST_CLASS_EXPORT(t2n_command_error) -// error serializing or deserializing a libt2n command packet +/// error serializing or deserializing a libt2n command packet 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 string& _message) + t2n_serialization_error(const std::string& _message) : t2n_exception(_message) { } t2n_serialization_error() { } - ipc_exception* clone() const + t2n_exception* clone() const { return new t2n_serialization_error(*this); } void do_throw() { throw *this; } }; -BOOST_CLASS_EXPORT(t2n_serialization_error) -// a runtime error within the remote function -// derive your own custom exceptions from this one +/** @brief a runtime error within the remote function. + derive your own custom exceptions from this one +*/ 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 string& _message) + t2n_runtime_error(const std::string& _message) : t2n_exception(_message) { } t2n_runtime_error() { } - ipc_exception* clone() const + t2n_exception* clone() const { return new t2n_runtime_error(*this); } void do_throw() { throw *this; } }; -BOOST_CLASS_EXPORT(t2n_runtime_error) -} +} // namespace libt2n #endif