sysd_monitor: Handle default for errors to monitor

If default is input, replace it with the three default errors to monitor
for

Tested:
- Relied on unit test

Change-Id: Ife92e74242d72b322f46f7f08d5a47068b31977d
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/systemd_target_parser.cpp b/systemd_target_parser.cpp
index d2cfa86..9656a46 100644
--- a/systemd_target_parser.cpp
+++ b/systemd_target_parser.cpp
@@ -17,6 +17,23 @@
             throw std::out_of_range("Found invalid error to monitor");
         }
     }
+    // See if default was in the errors to monitor, if so replace with defaults
+    auto errorItr =
+        std::find(errorsToMonitor.begin(), errorsToMonitor.end(), "default");
+    if (errorItr != errorsToMonitor.end())
+    {
+        // Verify default is the only entry
+        if (errorsToMonitor.size() != 1)
+        {
+            throw std::invalid_argument(
+                "default must be only error to monitor");
+        }
+        // delete "default" and insert defaults
+        errorsToMonitor.erase(errorItr);
+        errorsToMonitor.push_back("timeout");
+        errorsToMonitor.push_back("failed");
+        errorsToMonitor.push_back("dependency");
+    }
 }
 
 TargetErrorData parseFiles(const std::vector<std::string>& filePaths)