]> git.tdb.fi Git - libs/net.git/blobdiff - source/protocol.h
Exception changes
[libs/net.git] / source / protocol.h
index 4bde291ea5c263ce519ea4cac690a6120758fc92..75b3514bb43b2729c915902f7a33374e8b1b608c 100644 (file)
@@ -2,13 +2,29 @@
 #define MSP_NET_PROTOCOL_H_
 
 #include <map>
+#include <stdexcept>
 #include <vector>
-#include <msp/core/except.h>
 #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<P> *prcv = dynamic_cast<PacketReceiver<P> *>(&r);
                        if(!prcv)
-                               throw Exception("Packet type not supported by receiver");
+                               throw bad_packet("unsupported");
                        P pkt;
                        for(typename std::vector<FieldBase<P> *>::const_iterator i=fields.begin(); i!=fields.end(); ++i)
                                d = (*i)->disassemble(pkt, d, e);