-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathexception.cpp
More file actions
63 lines (61 loc) · 1.23 KB
/
Copy pathexception.cpp
File metadata and controls
63 lines (61 loc) · 1.23 KB
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
#include <Windows.h>
#include <string>
#include <stdexcept>
/*
exception type
0 int
1 char
2 std::exception
... DWORD64
*/
int exception(int exception_type) {
//int a = 0;
//__try {
// *(PDWORD)(nullptr) = -1;
// a = 2;
//}
//__except (EXCEPTION_EXECUTE_HANDLER) {
// printf("-----------\n");
// getchar();
// a = 1;
//}
try {
switch (exception_type) {
case 0:
throw 0;
case 1:
throw '1';
case 2:
throw std::exception("2");
case 3:
{
std::string s = "foo";
s.at(10);
}
default:
throw (DWORD64)-1;
}
return 0;
}
catch (int val) {
printf("exception code = %d\n", val);
return val;
}
catch (char val) {
printf("exception code = %c\n", val);
return val - '0';
}
catch (const std::out_of_range& e) {
printf("%s\n", e.what());
return 3;
}
catch (std::exception val) {
printf("exception code = %s\n", val.what());
return 2;
}
catch (...) {
printf("exception catched!!\n");
return 0;
}
//return a;
}