errors.cpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9 ** Includes
10 *****************************************************************************/
11 
12 #include <iostream>
13 #include "../../include/ecl/errors/compile_time_assert.hpp"
14 #include "../../include/ecl/errors/handlers.hpp"
15 #include "../../include/ecl/errors/run_time_functions.hpp"
16 #include "../../include/ecl/errors/macros.hpp"
17 
18 
19 /*****************************************************************************
20 ** Globals
21 *****************************************************************************/
25 template <int M, int N>
26 class Test {
27 public:
28  Test() {
29  ecl_compile_time_assert( M >= 0 );
30  ecl_compile_time_assert( N >= 0 );
31  }
32 };
36 /*****************************************************************************
37 ** Main
38 *****************************************************************************/
39 
40 int main() {
41 
42  std::cout << std::endl;
43  std::cout << "***********************************************************" << std::endl;
44  std::cout << " Error functions" << std::endl;
45  std::cout << "***********************************************************" << std::endl;
46  std::cout << std::endl;
47 
48  std::cout << "Constructing an error of type 'Unknown Error'" << std::endl;
49  std::cout << std::endl;
51  std::cout << "Error::what() " << std::endl;
52  std::cout << error.what() << std::endl;
53  std::cout << "Error::print(LOC) " << std::endl;
54  error.print(LOC);
55 
56  std::cout << std::endl;
57  std::cout << "***********************************************************" << std::endl;
58  std::cout << " Asserts and Aborts" << std::endl;
59  std::cout << "***********************************************************" << std::endl;
60  std::cout << std::endl;
61 
62  ecl::Error configuration_error(ecl::ConfigurationError);
63  Test<3,1> test;
64 // ecl_compile_time_assert(1 >= 3);
65 // ecl_verbose_compile_time_assert( 1 >= 0, BAD_INEQUALITY );
66 // ecl_run_time_abort ( LOC, ConfigurationError );
67 // ecl_run_time_abort ( LOC, "Custom error report." );
68  ecl_run_time_assert ( 2 < 1, LOC, configuration_error.flag() );
69 // ecl_run_time_assert ( 2 < 1, LOC, ConfigurationError );
70 // ecl_run_time_assert ( 2 < 1, LOC, "Inequality broken." );
71 
72  return 0;
73 }
74 
virtual ErrorFlag flag() const
The flag identifying the error identified with this error handler.
Definition: handlers.hpp:72
virtual const char * what() const
A simple string verbosely representing the error that is handled.
Definition: handlers.hpp:103
#define ecl_compile_time_assert(logical_expression)
#define LOC
Stringify the line of code you are at.
Definition: macros.hpp:67
virtual void print(const char *loc)
Print a location dependent message to standard out.
Definition: handlers.hpp:94
ecl_errors_PUBLIC void ecl_run_time_assert(bool requirement, const char *location, const char *msg)
Condition test, aborts with a programmable error string if it fails.
The primary error handler for ecl libraries.
Definition: handlers.hpp:58
int main()
Definition: errors.cpp:40


ecl_errors
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:09:04