src/work/klao/error_test.cc
author alpar
Fri, 28 Jan 2005 08:53:48 +0000
changeset 1101 9286569c3749
child 1120 5d8d64bde9c5
permissions -rw-r--r--
Wrap a long line
klao@1067
     1
#include <iostream>
klao@1067
     2
#include <string>
klao@1067
     3
klao@1067
     4
#define LEMON_ASSERT_ABORT 0
klao@1067
     5
#include <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@1067
    18
    e.set_file(fn);
klao@1067
    19
    e.set_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@1067
    30
  catch(exception &e) {
klao@1067
    31
    cerr << "Exception caught: " << endl;
klao@1067
    32
    cerr << e.what() << endl;
klao@1067
    33
  }
klao@1067
    34
klao@1067
    35
  try {
klao@1067
    36
    fail_assert();
klao@1067
    37
  }
klao@1067
    38
  catch(exception &e) {
klao@1067
    39
    cerr << "Exception caught: " << endl;
klao@1067
    40
    cerr << e.what() << endl;
klao@1067
    41
  }
klao@1067
    42
klao@1067
    43
  // assert(1==0);
klao@1067
    44
  LEMON_ASSERT(1==0, "Ellentmondas");
klao@1067
    45
  LEMON_FIXME("Nincs kesz");
klao@1067
    46
}
klao@1067
    47
klao@1067
    48
#undef LEMON_ASSERT_HANDLER
klao@1067
    49
#define LEMON_ASSERT_HANDLER ::lemon::assert_fail_throw
klao@1067
    50
klao@1067
    51
#include <error.h>
klao@1067
    52
klao@1067
    53
void fail_assert() {
klao@1067
    54
  LEMON_ASSERT(2*2==5, "Marson vagyunk");
klao@1067
    55
}
klao@1067
    56
klao@1067
    57