dissect: print offset of parsing error

Change-Id: I2209a16330e513b46abe2dfcc57ca780b3478b82
diff --git a/tools/dissect/ndn-dissect.cpp b/tools/dissect/ndn-dissect.cpp
index 907eef6..4971d03 100644
--- a/tools/dissect/ndn-dissect.cpp
+++ b/tools/dissect/ndn-dissect.cpp
@@ -118,9 +118,9 @@
   if (block.elements().empty()) {
     os << " [[";
     name::Component(block.value(), block.value_size()).toUri(os);
-    os<< "]]";
+    os << "]]";
   }
-  os << std::endl;
+  os << "\n";
 
   util::IndentedStream os2(os, "  ");
   std::for_each(block.elements_begin(), block.elements_end(),
@@ -130,13 +130,16 @@
 void
 NdnDissect::dissect(std::ostream& os, std::istream& is)
 {
-  while (is.peek() != std::char_traits<char>::eof()) {
-    try {
-      printBlock(os, Block::fromStream(is));
+  size_t offset = 0;
+  try {
+    while (is.peek() != std::istream::traits_type::eof()) {
+      auto block = Block::fromStream(is);
+      printBlock(os, block);
+      offset += block.size();
     }
-    catch (const std::exception& e) {
-      std::cerr << "ERROR: " << e.what() << std::endl;
-    }
+  }
+  catch (const std::exception& e) {
+    std::cerr << "ERROR: " << e.what() << " at offset " << offset << "\n";
   }
 }