tools: exit with non-zero on advertise/withdraw error

refs #5271

Change-Id: I287fc5746ac1fd2930bb85ac49e5ad732abd3581
diff --git a/tools/nlsrc.hpp b/tools/nlsrc.hpp
index 99a441c..a64c940 100644
--- a/tools/nlsrc.hpp
+++ b/tools/nlsrc.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2022,  The University of Memphis,
+ * Copyright (c) 2014-2023,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -68,6 +68,12 @@
   bool
   dispatch(ndn::span<std::string> subcommand);
 
+  int
+  getExitCode() const
+  {
+    return m_exitCode;
+  }
+
 private:
   void
   runNextStep();
@@ -162,6 +168,8 @@
   std::map<ndn::Name, Router> m_routers;
   std::string m_rtString;
   std::deque<std::function<void()>> m_fetchSteps;
+
+  int m_exitCode = 0;
 };
 
 } // namespace nlsrc