dump: handle exceptions thrown by lp::Packet::wireDecode()
Change-Id: Ia3bd8a4f57c70313a589c197ee453f517664ec43
Refs: #3943
diff --git a/tools/dump/ndndump.cpp b/tools/dump/ndndump.cpp
index 77743a8..4020d45 100644
--- a/tools/dump/ndndump.cpp
+++ b/tools/dump/ndndump.cpp
@@ -189,7 +189,13 @@
Block netPacket;
if (block.type() == lp::tlv::LpPacket) {
- lpPacket = lp::Packet(block);
+ try {
+ lpPacket.wireDecode(block);
+ }
+ catch (const tlv::Error& e) {
+ std::cout << os.str() << ", " << "INVALID-NDNLPv2-PACKET: " << e.what() << std::endl;
+ return;
+ }
Buffer::const_iterator begin, end;
if (lpPacket.has<lp::FragmentField>()) {
@@ -237,7 +243,7 @@
}
}
catch (const tlv::Error& e) {
- std::cerr << e.what() << std::endl;
+ std::cout << os.str() << ", " << "INVALID-PACKET: " << e.what() << std::endl;
}
}