19 #include <ecl/config/ecl.hpp> 20 #include "../../include/ecl/exceptions/exception.hpp" 21 #include "../../include/ecl/exceptions/data_exception.hpp" 22 #include "../../include/ecl/exceptions/macros.hpp" 23 #include "../../include/ecl/exceptions/standard_exception.hpp" 29 #include <ecl/config/ecl.hpp> 30 #ifndef ECL_DISABLE_EXCEPTIONS 55 int main(
int argc,
char **argv) {
57 std::cout << std::endl;
58 std::cout <<
"***********************************************************" << std::endl;
59 std::cout <<
" Standard Exceptions" << std::endl;
60 std::cout <<
"***********************************************************" << std::endl;
61 std::cout << std::endl;
66 std::cout << e.
what() << std::endl;
71 std::cout << e.
what() << std::endl;
76 std::cout << e.
what() << std::endl;
81 std::cout << e.
what() << std::endl;
86 std::cout << e.
what() << std::endl;
91 std::cout << e.
what() << std::endl;
96 std::cout << e.
what() << std::endl;
101 std::cout << e.
what() << std::endl;
106 std::cout << e.
what() << std::endl;
111 std::cout << e.
what() << std::endl;
116 std::cout << e.
what() << std::endl;
121 std::cout << e.
what() << std::endl;
126 std::cout << e.
what() << std::endl;
131 std::cout << e.
what() << std::endl;
136 std::cout << e.
what() << std::endl;
141 std::cout << e.
what() << std::endl;
146 std::cout << e.
what() << std::endl;
151 std::cout << e.
what() << std::endl;
156 std::cout << e.
what() << std::endl;
161 std::cout << e.
what() << std::endl;
166 std::cout << e.
what() << std::endl;
171 std::cout << e.
what() << std::endl;
176 std::cout << e.
what() << std::endl;
179 std::cout << std::endl;
180 std::cout <<
"***********************************************************" << std::endl;
181 std::cout <<
" Standard Exceptions - Custom Message" << std::endl;
182 std::cout <<
"***********************************************************" << std::endl;
183 std::cout << std::endl;
188 std::cout << e.
what() << std::endl;
191 std::cout << std::endl;
192 std::cout <<
"***********************************************************" << std::endl;
193 std::cout <<
" Standard Exceptions - Custom Message" << std::endl;
194 std::cout <<
"***********************************************************" << std::endl;
195 std::cout << std::endl;
199 std::cout << e.
what() << std::endl;
202 std::cout << std::endl;
203 std::cout <<
"***********************************************************" << std::endl;
204 std::cout <<
" Assert Exception Macro" << std::endl;
205 std::cout <<
"***********************************************************" << std::endl;
206 std::cout << std::endl;
211 std::cout << e.
what() << std::endl;
214 std::cout << std::endl;
215 std::cout <<
"***********************************************************" << std::endl;
216 std::cout <<
" Debug Throw Macro" << std::endl;
217 std::cout <<
"***********************************************************" << std::endl;
218 std::cout << std::endl;
223 std::cout << e.
what() << std::endl;
226 std::cout << std::endl;
227 std::cout <<
"***********************************************************" << std::endl;
228 std::cout <<
" Rethrowing" << std::endl;
229 std::cout <<
"***********************************************************" << std::endl;
230 std::cout << std::endl;
238 std::cout << e2.
what() << std::endl;
242 std::cout << std::endl;
243 std::cout <<
"***********************************************************" << std::endl;
244 std::cout <<
" Try Catch" << std::endl;
245 std::cout <<
"***********************************************************" << std::endl;
246 std::cout << std::endl;
249 std::cout <<
"An ecl try-catch block." << std::endl;
250 std::cout << std::endl;
253 std::cout <<
"Try" << std::endl;
256 std::cout <<
"Catch" << std::endl;
257 std::cout << e.
what() << std::endl;
259 std::cout <<
"An debug try-catch block." << std::endl;
260 std::cout << std::endl;
262 std::cout <<
"Try" << std::endl;
265 std::cout <<
"Catch" << std::endl;
270 std::cout << std::endl;
271 std::cout <<
"***********************************************************" << std::endl;
272 std::cout <<
" Data Exception" << std::endl;
273 std::cout <<
"***********************************************************" << std::endl;
274 std::cout << std::endl;
279 std::cout <<
"Data: " << e.
data() << std::endl;
280 std::cout << e.
what() << std::endl;
283 std::cout << std::endl;
284 std::cout <<
"***********************************************************" << std::endl;
285 std::cout <<
" Passed" << std::endl;
286 std::cout <<
"***********************************************************" << std::endl;
287 std::cout << std::endl;
297 int main(
int argc,
char **argv) {
298 std::cout <<
"Ecl exceptions are unavailable (ecl was compiled with ECL_DISABLE_EXCEPTIONS)." << std::endl;
#define ecl_throw(exception)
Standard ecl throw exception throw.
Extended exception class that bundles location, message and data.
#define ecl_debug_try
The try part of a try-catch macro matching ecl_debug_throw/ecl_assert_throw calls.
#define ecl_assert_throw(expression, exception)
Debug mode throw with a logical condition check.
Standard exception type, provides code location and error string.
const char * what() const
int main(int argc, char **argv)
#define ecl_debug_catch(exception)
The catch part of a try-catch macro matching ecl_debug_throw/ecl_assert_throw calls.
const Data & data() const
The bundled data object.
#define ecl_debug_throw(exception)
Debug mode exception throw.
#define ecl_catch(exception)
The catch part of a try-catch macro matching ecl_throw calls.
const char * what() const
#define ecl_try
The try part of a try-catch macro matching ecl_throw calls.