-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathexceptions.js
More file actions
81 lines (76 loc) · 1.72 KB
/
exceptions.js
File metadata and controls
81 lines (76 loc) · 1.72 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import 'dummy';
function e1() {
let array = [source('e1.1')];
try {
array.forEach(x => {
throw x;
});
array.forEach(x => {
throw source('e1.2');
});
array.forEach(() => {
throw source('e1.3'); // Same as e1.2 but without callback parameters
});
} catch (err) {
sink(err); // $ hasValueFlow=e1.2 hasValueFlow=e1.3 hasValueFlow=e1.1
}
}
function e2() {
let array = [source('e2.1')];
try {
array.unknown(x => {
throw x;
});
array.unknown(x => {
throw source('e2.2');
});
} catch (err) {
sink(err); // $ hasValueFlow=e2.2
}
}
function e3() {
const events = getSomething();
try {
events.addEventListener('click', () =>{
throw source('e3.1');
});
events.addListener('click', () =>{
throw source('e3.2');
});
events.on('click', () =>{
throw source('e3.3');
});
events.unknownMethod('click', () =>{
throw source('e3.4');
});
} catch (err) {
sink(err); // $ hasValueFlow=e3.4
}
}
function e4() {
function thrower(array) {
array.forEach(x => { throw x });
}
try {
thrower([source("e4.1")]);
} catch (e) {
sink(e); // $ hasValueFlow=e4.1
}
try {
thrower(["safe"]);
} catch (e) {
sink(e);
}
}
async function e5() {
try {
Promise.resolve(0).finally(() => {
throw source("e5.1");
});
await Promise.resolve(0).finally(() => {
throw source("e5.2");
});
} catch (e) {
sink(e); // $ hasValueFlow=e5.2
}
}