src/work/klao/error_test.cc
author ladanyi
Thu, 14 Apr 2005 12:09:35 +0000
changeset 1351 551ffd3bcbb7
parent 1120 5d8d64bde9c5
permissions -rw-r--r--
- removed unnecessary include dirs
klao@1067
     1
#include <iostream>
klao@1067
     2
#include <string>
klao@1067
     3
klao@1067
     4
#define LEMON_ASSERT_ABORT 0
klao@1122
     5
#include <lemon/error.h>
klao@1067
     6
klao@1067
     7
using namespace std;
klao@1067
     8
klao@1067
     9
void parse_line() {
klao@1067
    10
  throw lemon::DataFormatError("Syntax error");
klao@1067
    11
}
klao@1067
    12
klao@1067
    13
void parse_file(string fn) {
klao@1067
    14
  try {
klao@1067
    15
    parse_line();
klao@1067
    16
  }
klao@1067
    17
  catch(lemon::DataFormatError &e) {
klao@1120
    18
    e.file(fn);
klao@1120
    19
    e.line(5);
klao@1067
    20
    throw;
klao@1067
    21
  }
klao@1067
    22
}
klao@1067
    23
klao@1067
    24
void fail_assert();
klao@1067
    25
klao@1067
    26
int main() {
klao@1067
    27
  try {
klao@1067
    28
    parse_file("input.txt");
klao@1067
    29
  }
klao@1120
    30
  catch(lemon::Exception &e) {
klao@1120
    31
    cerr << "Exception '" << e.exceptionName()
klao@1120
    32
	 << "' caught: " << endl;
klao@1120
    33
    cerr << e.what() << endl;
klao@1120
    34
  }
klao@1067
    35
  catch(exception &e) {
klao@1067
    36
    cerr << "Exception caught: " << endl;
klao@1067
    37
    cerr << e.what() << endl;
klao@1067
    38
  }
klao@1067
    39
klao@1067
    40
  try {
klao@1120
    41
    throw lemon::LogicError();
klao@1120
    42
  }
klao@1120
    43
  catch(lemon::Exception &e) {
klao@1120
    44
    cerr << "Exception '" << e.exceptionName()
klao@1120
    45
	 << "' caught: " << endl;
klao@1120
    46
    cerr << e.what() << endl;
klao@1120
    47
  }
klao@1120
    48
klao@1120
    49
  try {
klao@1067
    50
    fail_assert();
klao@1067
    51
  }
klao@1120
    52
  catch(lemon::Exception &e) {
klao@1120
    53
    cerr << "Exception '" << e.exceptionName()
klao@1120
    54
	 << "' caught: " << endl;
klao@1120
    55
    cerr << e.what() << endl;
klao@1120
    56
  }
klao@1067
    57
  catch(exception &e) {
klao@1067
    58
    cerr << "Exception caught: " << endl;
klao@1067
    59
    cerr << e.what() << endl;
klao@1067
    60
  }
klao@1067
    61
klao@1120
    62
  cerr << endl;
klao@1120
    63
klao@1067
    64
  // assert(1==0);
klao@1067
    65
  LEMON_ASSERT(1==0, "Ellentmondas");
klao@1067
    66
  LEMON_FIXME("Nincs kesz");
klao@1067
    67
}
klao@1067
    68
klao@1067
    69
#undef LEMON_ASSERT_HANDLER
klao@1120
    70
#define LEMON_ASSERT_EXCEPTION
klao@1067
    71
klao@1122
    72
#include <lemon/error.h>
klao@1067
    73
klao@1067
    74
void fail_assert() {
klao@1067
    75
  LEMON_ASSERT(2*2==5, "Marson vagyunk");
klao@1067
    76
}