X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprotocol.cpp;h=d56ac77a09f70eff7137da98beef2eb7112d8978;hb=21c596567e3b6fd794ed6af73d304ce2bc70e58f;hp=3e7d479b52407f4bca47f3057fdeef7ed507fd96;hpb=f9cc7ff2e1e5af865220e9fbe16673619ecb78bd;p=libs%2Fnet.git diff --git a/source/protocol.cpp b/source/protocol.cpp index 3e7d479..d56ac77 100644 --- a/source/protocol.cpp +++ b/source/protocol.cpp @@ -8,6 +8,8 @@ using namespace std; namespace { +using Msp::Net::buffer_error; + template class Assembler { @@ -32,7 +34,7 @@ char *Assembler::assemble(const T &v, char *data, char *end) for(unsigned i=0; i::assemble(const string &v, char *data, char *end) { data = Assembler::assemble(v.size(), data, end); if(end-data(v.size())) - throw Msp::Exception("Out of buffer space"); + throw buffer_error("overflow"); memcpy(data, v.data(), v.size()); return data+v.size(); } @@ -64,7 +66,7 @@ const char *Assembler::disassemble(T &v, const char *data, const char *end) for(unsigned i=0; i::disassemble(string &v, const char *data, const ch unsigned short size; data = Assembler::disassemble(size, data, end); if(end-datasize) - throw InvalidParameterValue("Not enough data for packet"); + throw bad_packet("truncated"); const PacketDefBase &pdef = get_packet_by_id(id); const char *ptr = pdef.disassemble(rcv, data+4, data+psz); return ptr-data;