blob: 88e772957455decaaa169ea700cabe42b515b0bb (
plain) (
blame)
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
|
#include <vespa/vespalib/util/exceptions.h>
using namespace vespalib;
void throwE() {
ExceptionWithPayload e("caught or not");
throw e;
}
void silenceE() {
ExceptionWithPayload e("caught or not");
e.setPayload(std::make_unique<SilenceUncaughtException>(e));
throw e;
}
void throwAndCatch() {
try {
silenceE();
} catch (const ExceptionWithPayload & e) {
printf("caught it\n");
}
}
int main(int argc, char *argv[]) {
if (argc != 2) {
return 77;
}
if (strcmp("uncaught", argv[1]) == 0) {
throwE();
} else if (strcmp("silenced_and_caught", argv[1]) == 0) {
throwAndCatch();
} else if (strcmp("uncaught_after_silenced_and_caught", argv[1]) == 0) {
throwAndCatch();
throwE();
} else if (strcmp("silenced_and_uncaught", argv[1]) == 0) {
silenceE();
} else {
return 55;
}
return 0;
}
|