-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.c
68 lines (59 loc) · 1.15 KB
/
example.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <stdio.h>
#include "AMException.h"
void func() {
puts("throwing 1");
THROW (1);
}
void func2() {
TRY {
puts("inner try");
func();
} CATCH (2) {
puts("This should not happen");
} FINALLY {
puts("inner finally");
} TRY_END;
}
void func3() {
puts("throwing 1");
THROW_ARG (1, (void*)"Hello from func3!");
}
int main() {
TRY {
puts("try");
func2();
puts("This should not happen");
} CATCH (1) {
puts("catch 1");
} CATCH_ALL {
puts("This should not happen");
} TRY_END;
TRY {
puts("try 2");
puts("throwing 2");
THROW (2);
} CATCH (1) {
puts("catch 1");
} CATCH_ALL {
puts("catch all");
} FINALLY {
puts("finally");
} TRY_END;
TRY {
puts("try3");
func3();
} CATCH (1) {
puts((char*)AMException.arg);
} TRY_END;
TRY {
puts("try 4");
puts("throwing 2");
THROW (2);
} CATCH (1) {
puts("catch 1");
} FINALLY {
puts("finally");
} TRY_END;
puts("This should not happen");
return 0;
}