Improve error handling for exceptions and asserts
The phosphor-psu-code-manager application currently exits abnormally due
to the following conditions:
* Uncaught exception
* False assert() statement
An abnormal exit can result in a core dump and/or a BMC dump. It also
causes the service to be restarted. If the failure condition remains,
the restarts will fail repeatedly, and systemd will stop trying to start
the service.
Improve error handling for exceptions in the following ways:
* Add try/catch blocks to the following locations:
* Code that calls functions that throw and needs to handle exceptions.
* For example, code looping over PSU objects may need to handle an
exception for one PSU and then continue to the remaining PSUs.
* D-Bus PropertiesChanged and InterfacesAdded event handlers.
* Do not allow exceptions to escape to the sdbusplus stack frames.
* main()
* Last line of defense; catching avoids a core dump.
* Write exception error message to the journal if appropriate
Replace assert statements with exceptions or error messages to the
journal.
Tested:
* Tested all modified functions/methods.
* Verified that all exceptions were caught and logged to the journal if
appropriate.
* Verified that asserts were replaced by exceptions and logging.
* See complete test plan at
https://gist.github.com/smccarney/b4bf568639fedd269c9737234fa2803d
Change-Id: I933386e94f43a915b301d6aef7d91691816a0548
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
diff --git a/src/activation.hpp b/src/activation.hpp
index dc708e9..015f524 100644
--- a/src/activation.hpp
+++ b/src/activation.hpp
@@ -16,6 +16,7 @@
#include <xyz/openbmc_project/Software/ExtendedVersion/server.hpp>
#include <queue>
+#include <string>
class TestActivation;
@@ -238,6 +239,8 @@
/** @brief Construct the systemd service name
*
+ * @details Throws an exception if an error occurs
+ *
* @param[in] psuInventoryPath - The PSU inventory to be updated.
*
* @return The escaped string of systemd unit to do the PSU update.