22 lines
592 B
C++
22 lines
592 B
C++
#pragma once
|
|
|
|
#include <exception>
|
|
#include <string>
|
|
|
|
/** MsgException -- an exception bearing a passed explanation message
|
|
*
|
|
* If `is_perror` is true, then the `strerror` corresponding message is appened
|
|
* to the message in `what()`.
|
|
*/
|
|
class MsgException : public std::exception {
|
|
public:
|
|
MsgException(const std::string& msg, int code=0, bool is_perror=false);
|
|
int errcode() const noexcept { return _code; }
|
|
const char* what() const noexcept { return _what.c_str(); };
|
|
|
|
private:
|
|
std::string _msg;
|
|
int _code;
|
|
std::string _what;
|
|
};
|