tools: specify common ipmi errors for humans

Add a check for common ipmi failure codes to the IPMI exception object
to make the messages more human readable.

Change-Id: If143a3a63748c258b2fdc4fd074cf5070c0b88d9
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/tools/ipmi_errors.hpp b/tools/ipmi_errors.hpp
index 210ef53..9f1a9f9 100644
--- a/tools/ipmi_errors.hpp
+++ b/tools/ipmi_errors.hpp
@@ -1,6 +1,7 @@
 #pragma once
 
 #include <exception>
+#include <map>
 #include <sstream>
 #include <string>
 
@@ -10,10 +11,26 @@
 class IpmiException : public std::exception
 {
   public:
+    const std::map<int, std::string> commonFailures = {
+        {0xc0, "busy"},
+        {0xc1, "invalid"},
+        {0xc3, "timeout"},
+    };
+
     explicit IpmiException(int cc)
     {
         std::ostringstream smessage;
-        smessage << "Received IPMI_CC: " << cc;
+
+        auto search = commonFailures.find(cc);
+        if (search != commonFailures.end())
+        {
+            smessage << "Received IPMI_CC: " << search->second;
+        }
+        else
+        {
+            smessage << "Received IPMI_CC: " << cc;
+        }
+
         message = smessage.str();
     }
     explicit IpmiException(const std::string& message) : message(message){};