62#define undefined_error 1000
63#define unknown_error 1001
64#define internal_error 1002
65#define no_such_file 1003
66#define no_such_variable 1004
67#define malformed_expr 1005
68#define no_authorization 1006
69#define cannot_read_file 1007
70#define not_implemented 1008
71#define dummy_message 1009
93class Error :
public std::exception
97 std::string _error_message;
103 Error() : exception(), _error_code(undefined_error) {}
118 : exception(), _error_code(ec), _error_message(std::move(msg)), d_file(std::move(file)), d_line(line)
129 explicit Error(std::string msg, std::string file =
"" ,
int line = 0)
130 : exception(), _error_code(unknown_error), _error_message(std::move(msg)), d_file(std::move(file)), d_line(line)
134 : exception(), _error_code(copy_from._error_code), _error_message(copy_from._error_message)
137 ~Error()
override =
default;
142 bool parse(FILE *fp);
143 void print(FILE *out)
const;
144 void print(std::ostream &out)
const;
150 std::string get_file()
const {
return d_file; }
151 void set_file(std::string f) { d_file = std::move(f); }
152 int get_line()
const {
return d_line; }
153 void set_line(
int l) { d_line = l; }
156 const char*
what() const noexcept
override {
157 return _error_message.c_str();
A class for error processing.
Error(ErrorCode ec, std::string msg, std::string file="", int line=0)
void set_error_message(std::string msg="")
void set_error_code(ErrorCode ec=undefined_error)
void print(FILE *out) const
const char * what() const noexcept override
The pointer is valid only for the lifetime of the Error instance. jhrg 9/22/20.
ErrorCode get_error_code() const
std::string get_error_message() const
Error(std::string msg, std::string file="", int line=0)
bool parse(FILE *fp)
Parse an Error object.
bool OK() const
Is the Error object valid?
top level DAP object to house generic methods
int ErrorCode
An enumerated type for common errors.