X-Git-Url: http://git.tdb.fi/?p=libs%2Fnet.git;a=blobdiff_plain;f=source%2Fprotocol.h;h=75b3514bb43b2729c915902f7a33374e8b1b608c;hp=4bde291ea5c263ce519ea4cac690a6120758fc92;hb=4696a776e2875697ea0d6a733609dd9c37918971;hpb=65b029e8334d4dfc9a6161fc04740b03d56a8e2f diff --git a/source/protocol.h b/source/protocol.h index 4bde291..75b3514 100644 --- a/source/protocol.h +++ b/source/protocol.h @@ -2,13 +2,29 @@ #define MSP_NET_PROTOCOL_H_ #include +#include #include -#include #include "receiver.h" namespace Msp { namespace Net { +class bad_packet: public std::runtime_error +{ +public: + bad_packet(const std::string &w): std::runtime_error(w) { } + virtual ~bad_packet() throw() { } +}; + + +class buffer_error: public std::runtime_error +{ +public: + buffer_error(const std::string &w): std::runtime_error(w) { } + virtual ~buffer_error() throw() { } +}; + + class Protocol { private: @@ -88,7 +104,7 @@ protected: { PacketReceiver

*prcv = dynamic_cast *>(&r); if(!prcv) - throw Exception("Packet type not supported by receiver"); + throw bad_packet("unsupported"); P pkt; for(typename std::vector *>::const_iterator i=fields.begin(); i!=fields.end(); ++i) d = (*i)->disassemble(pkt, d, e);