-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathcexception.cpp
More file actions
32 lines (27 loc) · 932 Bytes
/
cexception.cpp
File metadata and controls
32 lines (27 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//
// Project: clibparser
// Author: bajdcc
//
#include <cassert>
#include "cexception.h"
namespace clib {
std::tuple<ex_t, string_t> ex_string_list[] = {
std::make_tuple(ex_none, ""),
std::make_tuple(ex_unit, "UNIT ERROR"),
std::make_tuple(ex_ast, "AST ERROR"),
std::make_tuple(ex_parser, "PARSER ERROR"),
std::make_tuple(ex_vm, "VM ERROR"),
std::make_tuple(ex_gen, "GEN ERROR"),
std::make_tuple(ex_gui, "GUI ERROR"),
std::make_tuple(ex_mem, "MEMORY ERROR"),
std::make_tuple(ex_vfs, "VFS ERROR"),
};
const string_t &ex_str(ex_t t) {
assert(t >= ex_none && t <= ex_mem);
return std::get<1>(ex_string_list[t]);
}
cexception::cexception(ex_t e, const string_t &msg) noexcept : msg(msg), e(e) {}
string_t cexception::message() const {
return ex_str(e) + ": " + msg;
}
}