Patrick Venture | d2037c6 | 2019-03-15 10:29:47 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <exception> |
| 4 | #include <string> |
| 5 | |
| 6 | namespace google |
| 7 | { |
| 8 | namespace ipmi |
| 9 | { |
| 10 | |
| 11 | /** |
| 12 | * This can be used by the Handler object to throw an exception and suggest an |
| 13 | * IPMI return code to use for the error. |
| 14 | */ |
| 15 | class IpmiException : public std::exception |
| 16 | { |
| 17 | public: |
| 18 | explicit IpmiException(int ipmicc) : |
| 19 | _message("IPMI Code Received: " + std::to_string(ipmicc)), |
| 20 | _ipmicc(ipmicc) |
| 21 | { |
| 22 | } |
| 23 | |
| 24 | virtual const char* what() const noexcept override |
| 25 | { |
| 26 | return _message.c_str(); |
| 27 | } |
| 28 | |
| 29 | int getIpmiError() const |
| 30 | { |
| 31 | return _ipmicc; |
| 32 | } |
| 33 | |
| 34 | private: |
| 35 | std::string _message; |
| 36 | int _ipmicc; |
| 37 | }; |
| 38 | |
| 39 | } // namespace ipmi |
| 40 | } // namespace google |