const
{
if (! message.is<MIHPacket>())
- throw InvalidMIHPacketException("invalid packet chain");
+ throw InvalidMIHPacketException("invalid packet chain: ")
+ << (message.valid() ? message.typeId().prettyName() : "invalid packet")
+ << " != " << prettyName(typeid(MIHPacket));
MIHPacket::type::validate(message.as<MIHPacket>());
}
test::TestMessagePacket testMessage (test::TestMessagePacket::createAfter(mihPacket));
mihPacket.finalizeAll();
BOOST_CHECK_NO_THROW( MIHPacketType::validate( mihPacket));
+ mihPacket->messageId() = test::ValidatedTestMessagePacketType::MESSAGE_ID;
+ BOOST_CHECK_THROW( MIHPacketType::validate( mihPacket), InvalidMIHPacketException);
}
{
test::ValidatedTestMessagePacket testMessage (test::ValidatedTestMessagePacket::createAfter(mihPacket));
{
validateType( expectedType);
if (length() != expectedLength)
- throw InvalidMIHPacketException("invalid length in TLV.") << " Type: " << unsigned(type());
+ throw InvalidMIHPacketException("invalid length in TLV.") << " Type: " << unsigned(type())
+ << ", expected length: " << expectedLength << " got " << length();
}
//-/////////////////////////////////////////////////////////////////////////////////////////////////
byte. If the packet has been implemented correctly, this signals a malformed packet.
*/
struct TruncatedPacketException : public senf::Exception
- { TruncatedPacketException() : senf::Exception("truncated packet") {} };
+ {
+ TruncatedPacketException(std::string const & description = "")
+ : senf::Exception("truncated packet") { append( description); }
+ };
}