COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/work/klao/error_test.cc @ 1265:47c60ae9c26a

Last change on this file since 1265:47c60ae9c26a was 1122:3ce7fc516cca, checked in by Mihaly Barasz, 20 years ago

New error.h moved to lemon/

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