61#define undefined_error 1000
62#define unknown_error 1001
63#define internal_error 1002
64#define no_such_file 1003
65#define no_such_variable 1004
66#define malformed_expr 1005
67#define no_authorization 1006
68#define cannot_read_file 1007
69#define not_implemented 1008
70#define dummy_message 1009
92class Error :
public std::exception {
95 std::string _error_message;
101 Error() : exception(), _error_code(undefined_error) {}
116 : exception(), _error_code(ec), _error_message(std::move(msg)), d_file(std::move(file)), d_line(line) {}
126 explicit Error(std::string msg, std::string file =
"",
int line = 0)
127 : exception(), _error_code(unknown_error), _error_message(std::move(msg)), d_file(std::move(file)),
131 : exception(), _error_code(copy_from._error_code), _error_message(copy_from._error_message) {}
133 ~Error()
override =
default;
138 bool parse(FILE *fp);
139 void print(FILE *out)
const;
140 void print(std::ostream &out)
const;
146 std::string get_file()
const {
return d_file; }
147 void set_file(std::string f) { d_file = std::move(f); }
148 int get_line()
const {
return d_line; }
149 void set_line(
int l) { d_line = l; }
152 const char *
what() const noexcept
override {
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.