blob: 7d392a7b92befe70a9a05ab6496c51c25641414d [file] [log] [blame]
Patrick Ventured2037c62019-03-15 10:29:47 -07001#pragma once
2
3#include <exception>
4#include <string>
5
6namespace google
7{
8namespace 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 */
15class 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