-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy patherror.h
128 lines (103 loc) · 3.81 KB
/
error.h
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#pragma once
#include <cerrno>
#include <cstring>
#include <string>
class RedBaseError : public std::exception {
std::string _msg;
public:
RedBaseError(const std::string &msg) : _msg("Error: " + msg) {}
const char *what() const noexcept override { return _msg.c_str(); }
};
class InternalError : public RedBaseError {
public:
InternalError(const std::string &msg) : RedBaseError(msg) {}
};
// PF errors
class UnixError : public RedBaseError {
public:
UnixError() : RedBaseError(strerror(errno)) {}
};
class FileNotOpenError : public RedBaseError {
public:
FileNotOpenError(int fd) : RedBaseError("Invalid file descriptor: " + std::to_string(fd)) {}
};
class FileNotClosedError : public RedBaseError {
public:
FileNotClosedError(const std::string &filename) : RedBaseError("File is opened: " + filename) {}
};
class FileExistsError : public RedBaseError {
public:
FileExistsError(const std::string &filename) : RedBaseError("File already exists: " + filename) {}
};
class FileNotFoundError : public RedBaseError {
public:
FileNotFoundError(const std::string &filename) : RedBaseError("File not found: " + filename) {}
};
// RM errors
class RecordNotFoundError : public RedBaseError {
public:
RecordNotFoundError(int page_no, int slot_no)
: RedBaseError("Record not found: (" + std::to_string(page_no) + "," + std::to_string(slot_no) + ")") {}
};
class InvalidRecordSizeError : public RedBaseError {
public:
InvalidRecordSizeError(int record_size) : RedBaseError("Invalid record size: " + std::to_string(record_size)) {}
};
// IX errors
class InvalidColLengthError : public RedBaseError {
public:
InvalidColLengthError(int col_len) : RedBaseError("Invalid column length: " + std::to_string(col_len)) {}
};
class IndexEntryNotFoundError : public RedBaseError {
public:
IndexEntryNotFoundError() : RedBaseError("Index entry not found") {}
};
// SM errors
class DatabaseNotFoundError : public RedBaseError {
public:
DatabaseNotFoundError(const std::string &db_name) : RedBaseError("Database not found: " + db_name) {}
};
class DatabaseExistsError : public RedBaseError {
public:
DatabaseExistsError(const std::string &db_name) : RedBaseError("Database already exists: " + db_name) {}
};
class TableNotFoundError : public RedBaseError {
public:
TableNotFoundError(const std::string &tab_name) : RedBaseError("Table not found: " + tab_name) {}
};
class TableExistsError : public RedBaseError {
public:
TableExistsError(const std::string &tab_name) : RedBaseError("Table already exists: " + tab_name) {}
};
class ColumnNotFoundError : public RedBaseError {
public:
ColumnNotFoundError(const std::string &col_name) : RedBaseError("Column not found: " + col_name) {}
};
class IndexNotFoundError : public RedBaseError {
public:
IndexNotFoundError(const std::string &tab_name, const std::string &col_name)
: RedBaseError("Index not found: " + tab_name + '.' + col_name) {}
};
class IndexExistsError : public RedBaseError {
public:
IndexExistsError(const std::string &tab_name, const std::string &col_name)
: RedBaseError("Index already exists: " + tab_name + '.' + col_name) {}
};
// QL errors
class InvalidValueCountError : public RedBaseError {
public:
InvalidValueCountError() : RedBaseError("Invalid value count") {}
};
class StringOverflowError : public RedBaseError {
public:
StringOverflowError() : RedBaseError("String is too long") {}
};
class IncompatibleTypeError : public RedBaseError {
public:
IncompatibleTypeError(const std::string &lhs, const std::string &rhs)
: RedBaseError("Incompatible type error: lhs " + lhs + ", rhs " + rhs) {}
};
class AmbiguousColumnError : public RedBaseError {
public:
AmbiguousColumnError(const std::string &col_name) : RedBaseError("Ambiguous column: " + col_name) {}
};