-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCustomExceptions.hpp
162 lines (142 loc) · 5.28 KB
/
CustomExceptions.hpp
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#pragma once
#include <cstddef>
#include <exception>
#include <string>
#include <utility>
namespace cda_rail::exceptions {
class ModelCreationException : public std::exception {
public:
ModelCreationException() : error_message("Model creation failed.") {}
explicit ModelCreationException(std::string message)
: error_message(std::move(message)) {}
[[nodiscard]] const char* what() const noexcept override {
return error_message.c_str();
}
private:
std::string error_message;
};
class ExportException : public std::exception {
public:
ExportException() : error_message("Export failed.") {}
explicit ExportException(std::string message)
: error_message(std::move(message)) {}
[[nodiscard]] const char* what() const noexcept override {
return error_message.c_str();
}
private:
std::string error_message;
};
class ConsistencyException : public std::exception {
public:
ConsistencyException() : error_message("Consistency check failed.") {}
explicit ConsistencyException(std::string message)
: error_message(std::move(message)) {}
[[nodiscard]] const char* what() const noexcept override {
return error_message.c_str();
}
private:
std::string error_message;
};
class InvalidInputException : public std::exception {
public:
InvalidInputException() : error_message("Invalid input.") {}
explicit InvalidInputException(std::string message)
: error_message(std::move(message)) {}
[[nodiscard]] const char* what() const noexcept override {
return error_message.c_str();
}
private:
std::string error_message;
};
class ImportException : public std::exception {
public:
ImportException() : error_message("Import failed.") {}
explicit ImportException(const std::string& import_name)
: error_message("Import of " + import_name + " failed.") {}
[[nodiscard]] const char* what() const noexcept override {
return error_message.c_str();
}
private:
std::string error_message;
};
class VertexNotExistentException : public std::exception {
public:
VertexNotExistentException()
: error_message("Some vertex specified does not exist.") {}
explicit VertexNotExistentException(const std::string& vertex_name)
: error_message("Vertex " + vertex_name + " does not exist") {}
explicit VertexNotExistentException(size_t vertex_id)
: error_message("Vertex with ID " + std::to_string(vertex_id) +
" does not exist") {}
[[nodiscard]] const char* what() const noexcept override {
return error_message.c_str();
}
private:
std::string error_message;
};
class EdgeNotExistentException : public std::exception {
public:
EdgeNotExistentException()
: error_message("Some edge specified does not exist.") {}
explicit EdgeNotExistentException(const std::string& edge_name)
: error_message("Edge " + edge_name + " does not exist.") {}
explicit EdgeNotExistentException(size_t edge_id)
: error_message("Edge with ID " + std::to_string(edge_id) +
" does not exist.") {}
explicit EdgeNotExistentException(size_t source, size_t target)
: error_message("Edge connecting vertices with IDs " +
std::to_string(source) + "->" + std::to_string(target) +
" does not exist.") {}
explicit EdgeNotExistentException(const std::string& source,
const std::string& target)
: error_message("Edge connecting " + source + "->" + target +
" does not exist.") {}
[[nodiscard]] const char* what() const noexcept override {
return error_message.c_str();
}
private:
std::string error_message;
};
class TrainNotExistentException : public std::exception {
public:
TrainNotExistentException()
: error_message("Some train specified does not exist.") {}
explicit TrainNotExistentException(const std::string& train_name)
: error_message("Train " + train_name + " does not exist.") {}
explicit TrainNotExistentException(size_t train_id)
: error_message("Train with ID " + std::to_string(train_id) +
" does not exist.") {}
[[nodiscard]] const char* what() const noexcept override {
return error_message.c_str();
}
private:
std::string error_message;
};
class StationNotExistentException : public std::exception {
public:
StationNotExistentException()
: error_message("Some station specified does not exist.") {}
explicit StationNotExistentException(const std::string& station_name)
: error_message("Station " + station_name + " does not exist.") {}
[[nodiscard]] const char* what() const noexcept override {
return error_message.c_str();
}
private:
std::string error_message;
};
class ScheduleNotExistentException : public std::exception {
public:
ScheduleNotExistentException()
: error_message("Some schedule specified does not exist.") {}
explicit ScheduleNotExistentException(const std::string& schedule_name)
: error_message("Schedule " + schedule_name + " does not exist.") {}
explicit ScheduleNotExistentException(size_t schedule_id)
: error_message("Schedule with ID " + std::to_string(schedule_id) +
" does not exist.") {}
[[nodiscard]] const char* what() const noexcept override {
return error_message.c_str();
}
private:
std::string error_message;
};
} // namespace cda_rail::exceptions