Rev | Line | |
---|
[1067] | 1 | #include <iostream> |
---|
| 2 | #include <string> |
---|
| 3 | |
---|
| 4 | #define LEMON_ASSERT_ABORT 0 |
---|
[1122] | 5 | #include <lemon/error.h> |
---|
[1067] | 6 | |
---|
| 7 | using namespace std; |
---|
| 8 | |
---|
| 9 | void parse_line() { |
---|
| 10 | throw lemon::DataFormatError("Syntax error"); |
---|
| 11 | } |
---|
| 12 | |
---|
| 13 | void parse_file(string fn) { |
---|
| 14 | try { |
---|
| 15 | parse_line(); |
---|
| 16 | } |
---|
| 17 | catch(lemon::DataFormatError &e) { |
---|
[1120] | 18 | e.file(fn); |
---|
| 19 | e.line(5); |
---|
[1067] | 20 | throw; |
---|
| 21 | } |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | void fail_assert(); |
---|
| 25 | |
---|
| 26 | int main() { |
---|
| 27 | try { |
---|
| 28 | parse_file("input.txt"); |
---|
| 29 | } |
---|
[1120] | 30 | catch(lemon::Exception &e) { |
---|
| 31 | cerr << "Exception '" << e.exceptionName() |
---|
| 32 | << "' caught: " << endl; |
---|
| 33 | cerr << e.what() << endl; |
---|
| 34 | } |
---|
[1067] | 35 | catch(exception &e) { |
---|
| 36 | cerr << "Exception caught: " << endl; |
---|
| 37 | cerr << e.what() << endl; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | try { |
---|
[1120] | 41 | throw lemon::LogicError(); |
---|
| 42 | } |
---|
| 43 | catch(lemon::Exception &e) { |
---|
| 44 | cerr << "Exception '" << e.exceptionName() |
---|
| 45 | << "' caught: " << endl; |
---|
| 46 | cerr << e.what() << endl; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | try { |
---|
[1067] | 50 | fail_assert(); |
---|
| 51 | } |
---|
[1120] | 52 | catch(lemon::Exception &e) { |
---|
| 53 | cerr << "Exception '" << e.exceptionName() |
---|
| 54 | << "' caught: " << endl; |
---|
| 55 | cerr << e.what() << endl; |
---|
| 56 | } |
---|
[1067] | 57 | catch(exception &e) { |
---|
| 58 | cerr << "Exception caught: " << endl; |
---|
| 59 | cerr << e.what() << endl; |
---|
| 60 | } |
---|
| 61 | |
---|
[1120] | 62 | cerr << endl; |
---|
| 63 | |
---|
[1067] | 64 | // assert(1==0); |
---|
| 65 | LEMON_ASSERT(1==0, "Ellentmondas"); |
---|
| 66 | LEMON_FIXME("Nincs kesz"); |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | #undef LEMON_ASSERT_HANDLER |
---|
[1120] | 70 | #define LEMON_ASSERT_EXCEPTION |
---|
[1067] | 71 | |
---|
[1122] | 72 | #include <lemon/error.h> |
---|
[1067] | 73 | |
---|
| 74 | void fail_assert() { |
---|
| 75 | LEMON_ASSERT(2*2==5, "Marson vagyunk"); |
---|
| 76 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.