regulators: Add toErrorType() utility function

Add a utility function to convert a PhaseFaultType value to the
corresponding ErrorType value.

The ErrorType enumeration is used by the ErrorHistory class.

Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: Ia0e2c7789087f5782006fcb6c6ede0faedaf5e0b
diff --git a/phosphor-regulators/src/phase_fault.hpp b/phosphor-regulators/src/phase_fault.hpp
index fbcb255..18597c7 100644
--- a/phosphor-regulators/src/phase_fault.hpp
+++ b/phosphor-regulators/src/phase_fault.hpp
@@ -15,6 +15,8 @@
  */
 #pragma once
 
+#include "error_history.hpp"
+
 #include <string>
 
 namespace phosphor::power::regulators
@@ -51,6 +53,29 @@
 };
 
 /**
+ * Returns the ErrorType that corresponds to the specified PhaseFaultType.
+ *
+ * The ErrorType enum is used with the ErrorHistory class.
+ *
+ * @param type phase fault type
+ * @return error type
+ */
+inline ErrorType toErrorType(PhaseFaultType type)
+{
+    ErrorType errorType;
+    switch (type)
+    {
+        case PhaseFaultType::n:
+            errorType = ErrorType::phaseFaultN;
+            break;
+        case PhaseFaultType::n_plus_1:
+            errorType = ErrorType::phaseFaultNPlus1;
+            break;
+    }
+    return errorType;
+}
+
+/**
  * Returns the name of the specified PhaseFaultType.
  *
  * @param type phase fault type