diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ipmiblob/ipmi_errors.hpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/ipmiblob/ipmi_errors.hpp b/src/ipmiblob/ipmi_errors.hpp index e41b3cf..15a5d4c 100644 --- a/src/ipmiblob/ipmi_errors.hpp +++ b/src/ipmiblob/ipmi_errors.hpp @@ -10,7 +10,8 @@ namespace ipmiblob class IpmiException : public std::exception { public: - explicit IpmiException(const std::string& message) : _message(message){}; + IpmiException(const std::string& message, int code) : + _message(message), _ccode(code){}; static std::string messageFromIpmi(int cc) { @@ -31,7 +32,14 @@ class IpmiException : public std::exception } } - explicit IpmiException(int cc) : IpmiException(messageFromIpmi(cc)) + /* This will leave the code as 0, but by virtue of being an exception + * thrown, we'll know it was an error on the host-side. + */ + explicit IpmiException(const std::string& message) : _message(message) + { + } + + explicit IpmiException(int cc) : IpmiException(messageFromIpmi(cc), cc) { } @@ -40,8 +48,14 @@ class IpmiException : public std::exception return _message.c_str(); } + int code() const noexcept + { + return _ccode; + } + private: std::string _message; + int _ccode = 0; }; } // namespace ipmiblob |