-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptions.h
More file actions
80 lines (62 loc) · 2.52 KB
/
exceptions.h
File metadata and controls
80 lines (62 loc) · 2.52 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <exception>
static int exceptionExit = 255;
using namespace std;
class CubeException : public exception {
public:
std::string id;
std::string message;
int line;
int col;
std::string file;
CubeException(std::string message) : message(message) { }
CubeException(std::string id,
std::string message) :
id(id), message(message) { }
CubeException(std::string id,
std::string message,
std::string file,
int line,
int col) :
id(id), message(message), file(file), line(line), col(col) { }
const char* what() const noexcept { return message.c_str(); }
std::string loc() { return file + " line: " + std::to_string(line) + ", col: " + std::to_string(col); }
bool knowsWhere() { return line != 1 && col != 1; }
};
class CompilerParserException : public CubeException {
public:
explicit CompilerParserException(std::string message) : CubeException("C000", message) { }
};
class RescopeSaveException : public CubeException {
public:
explicit RescopeSaveException(std::string message) : CubeException("C001", message) { }
explicit RescopeSaveException(std::string file, int line, int col, std::string message) : CubeException("C001", message, file, line, col) { }
};
class NoSuchIdentifierException : public CubeException {
public:
explicit NoSuchIdentifierException(std::string message) : CubeException("C002", message) { }
explicit NoSuchIdentifierException(std::string file, int line, int col, std::string message) : CubeException("C002", message, file, line, col) { }
};
class NameErrorException : public CubeException {
public:
explicit NameErrorException(std::string message) : CubeException("C003", message) { }
};
class DescopeException : public CubeException {
public:
explicit DescopeException(std::string message) : CubeException("C004", message) { }
};
class ExecutablePackageNameException : public CubeException {
public:
explicit ExecutablePackageNameException(std::string message) : CubeException("C005", message) { }
};
class ExecutablePackageEntrypointException : public CubeException {
public:
explicit ExecutablePackageEntrypointException() : CubeException("C006", "missing main() function") { }
};
class CompilerObjectException : public CubeException {
public:
explicit CompilerObjectException(std::string message) : CubeException("C007", message) { }
};
class UnexpectedLoopException : public CubeException {
public:
explicit UnexpectedLoopException(std::string message) : CubeException("C008", message) { }
};