summaryrefslogtreecommitdiffstats
path: root/src/ipmiblob/ipmi_errors.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipmiblob/ipmi_errors.hpp')
-rw-r--r--src/ipmiblob/ipmi_errors.hpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/ipmiblob/ipmi_errors.hpp b/src/ipmiblob/ipmi_errors.hpp
new file mode 100644
index 0000000..9f1a9f9
--- /dev/null
+++ b/src/ipmiblob/ipmi_errors.hpp
@@ -0,0 +1,47 @@
+#pragma once
+
+#include <exception>
+#include <map>
+#include <sstream>
+#include <string>
+
+namespace host_tool
+{
+
+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;
+
+ 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){};
+
+ virtual const char* what() const noexcept override
+ {
+ return message.c_str();
+ }
+
+ private:
+ std::string message;
+};
+
+} // namespace host_tool
OpenPOWER on IntegriCloud