hydrobricks
Loading...
Searching...
No Matches
Exceptions.h
Go to the documentation of this file.
1#ifndef EXCEPTIONS_H
2#define EXCEPTIONS_H
3
4#include <wx/string.h>
5
6#include <stdexcept>
7#include <string>
8
29// ============================================================================
30// Root Exception
31// ============================================================================
32
40class HydrobricksError : public std::runtime_error {
41 public:
42 explicit HydrobricksError(const char* msg)
43 : std::runtime_error(msg) {}
44
45 explicit HydrobricksError(const std::string& msg)
46 : std::runtime_error(msg) {}
47
48 explicit HydrobricksError(const wxString& msg)
49 : std::runtime_error(std::string(msg.mb_str())) {}
50
51 virtual ~HydrobricksError() = default;
52};
53
54// ============================================================================
55// Input Validation Errors (std::invalid_argument base) - User's fault
56// ============================================================================
57
69 public:
70 explicit InputError(const char* msg)
71 : HydrobricksError(msg) {}
72
73 explicit InputError(const std::string& msg)
74 : HydrobricksError(msg) {}
75
76 explicit InputError(const wxString& msg)
77 : HydrobricksError(msg) {}
78
79 virtual ~InputError() = default;
80};
81
97 public:
98 explicit ModelConfigError(const char* msg)
99 : HydrobricksError(msg) {}
100
101 explicit ModelConfigError(const std::string& msg)
102 : HydrobricksError(msg) {}
103
104 explicit ModelConfigError(const wxString& msg)
105 : HydrobricksError(msg) {}
106
107 virtual ~ModelConfigError() = default;
108};
109
110// ============================================================================
111// Internal Logic Errors (std::logic_error base) - Programmer's fault
112// ============================================================================
113
123 public:
125 : HydrobricksError(_("Function not yet implemented")) {}
126
127 explicit NotImplemented(const char* msg)
128 : HydrobricksError(msg) {}
129
130 explicit NotImplemented(const std::string& msg)
131 : HydrobricksError(msg) {}
132
133 explicit NotImplemented(const wxString& msg)
134 : HydrobricksError(msg) {}
135
136 virtual ~NotImplemented() = default;
137};
138
148 public:
150 : HydrobricksError(_("This should not happen...")) {}
151
152 explicit ShouldNotHappen(const char* msg)
153 : HydrobricksError(msg) {}
154
155 explicit ShouldNotHappen(const std::string& msg)
156 : HydrobricksError(msg) {}
157
158 explicit ShouldNotHappen(const wxString& msg)
159 : HydrobricksError(msg) {}
160
161 virtual ~ShouldNotHappen() = default;
162};
163
164// ============================================================================
165// Runtime Errors (std::runtime_error base)
166// ============================================================================
167
176 public:
177 explicit RuntimeError(const char* msg)
178 : HydrobricksError(msg) {}
179
180 explicit RuntimeError(const std::string& msg)
181 : HydrobricksError(msg) {}
182
183 explicit RuntimeError(const wxString& msg)
184 : HydrobricksError(msg) {}
185
186 virtual ~RuntimeError() = default;
187};
188
189#endif // EXCEPTIONS_H
Root exception class for all Hydrobricks-specific errors.
Definition Exceptions.h:40
Exception for invalid user input.
Definition Exceptions.h:68
Exception for model configuration or conception errors.
Definition Exceptions.h:96
Exception for unimplemented features.
Definition Exceptions.h:122
Exception for unexpected runtime conditions.
Definition Exceptions.h:175
Exception for code paths that should never be reached.
Definition Exceptions.h:147