| 1 | #include "cll1.h" |
| 2 | |
| 3 | void some_function(int i) |
| 4 | { |
| 5 | if(i==2) |
| 6 | { |
| 7 | fail(EVIL_FAILURE); |
| 8 | } |
| 9 | if(i==7) |
| 10 | { |
| 11 | some_function(2); |
| 12 | } |
| 13 | if(i==6) |
| 14 | { |
| 15 | fail(LOCAL_FAILURE); |
| 16 | } |
| 17 | printf("nuda #%d\n",i); |
| 18 | } |
| 19 | |
| 20 | program |
| 21 | { |
| 22 | try |
| 23 | { |
| 24 | some_function(1); |
| 25 | some_function(2); |
| 26 | some_function(6); |
| 27 | } |
| 28 | else_switch_failures |
| 29 | { |
| 30 | case EVIL_FAILURE: puts("serious failure detected!"); break; |
| 31 | default: puts("sorry, vole, error!"); |
| 32 | } |
| 33 | |
| 34 | try |
| 35 | { |
| 36 | some_function(1); |
| 37 | some_function(3); |
| 38 | some_function(6); |
| 39 | some_function(2); |
| 40 | } |
| 41 | else |
| 42 | { |
| 43 | puts("sorry, vole, error!"); |
| 44 | } |
| 45 | |
| 46 | try |
| 47 | { |
| 48 | some_function(1); |
| 49 | some_function(6); |
| 50 | } |
| 51 | else_catch(EVIL_FAILURE) |
| 52 | { |
| 53 | puts("Totally screwed."); |
| 54 | exit(-1); |
| 55 | } |
| 56 | else |
| 57 | { |
| 58 | puts("We survived this failure."); |
| 59 | } |
| 60 | |
| 61 | try |
| 62 | { |
| 63 | some_function(3); |
| 64 | some_function(7); |
| 65 | } |
| 66 | else_catch(EVIL_FAILURE) |
| 67 | { |
| 68 | puts("totally screwed."); |
| 69 | exit(-1); |
| 70 | } |
| 71 | else |
| 72 | { |
| 73 | puts("we survived this failure."); |
| 74 | } |
| 75 | } |