Packets: extended description of bad_cast exception in Packet.as()
[senf.git] / senf / Packets / Packet.cti
index d8e06c1..8184317 100644 (file)
@@ -62,7 +62,10 @@ prefix_ OtherPacket senf::Packet::as()
     const
 {
     if (!is<OtherPacket>())
-        throw WrapException<std::bad_cast>(std::bad_cast());
+        throw WrapException<std::bad_cast>(std::bad_cast())
+            << ": called packet::as() with wrong PacketType: "
+            << (valid() ? typeId().prettyName() : "invalid packet")
+            << " != " << prettyName(typeid(OtherPacket));
     return OtherPacket(ptr()->as<typename OtherPacket::type>());
 }