tools: updater: add exceptions for errors
Add custom exception for errors per TODO comments.
Change-Id: I14b89afe816724ff2bdb1761ef6e6a0a8217feed
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/tools/main.cpp b/tools/main.cpp
index be30230..b85f62b 100644
--- a/tools/main.cpp
+++ b/tools/main.cpp
@@ -18,6 +18,7 @@
#include "bt.hpp"
#include "ipmi_handler.hpp"
#include "lpc.hpp"
+#include "tool_errors.hpp"
#include "updater.hpp"
/* Use CLI11 argument parser once in openbmc/meta-oe or whatever. */
@@ -151,7 +152,15 @@
}
/* The parameters are all filled out. */
- return updaterMain(&blob, handler.get(), imagePath, signaturePath);
+ try
+ {
+ updaterMain(&blob, handler.get(), imagePath, signaturePath);
+ }
+ catch (const ToolException& e)
+ {
+ std::fprintf(stderr, "Exception received: %s\n", e.what());
+ return -1;
+ }
}
return 0;