-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
101 lines (89 loc) · 2.83 KB
/
index.html
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<html>
<head>
<link rel="stylesheet" href="styles.css" />
<title>my-javascript-crasher</title>
<script type="module">
import { BugSplat } from 'https://esm.sh/bugsplat@8.0.1';
const bugsplat = new BugSplat('fred', 'my-javascript-crasher', '1.0.0');
window.onerror = function (message, source, lineno, colno, error) {
bugsplat.post(error);
};
window.addEventListener('unhandledrejection', function (event) {
bugsplat.post(event.reason);
});
document.addEventListener('DOMContentLoaded', function () {
const buttons = document.querySelectorAll('.error');
buttons.forEach((button) => {
button.addEventListener('click', function (event) {
const id = event.target.id;
if (id === 'throw') {
throwStackFrame0();
} else if (id === 'type') {
typeStackFrame0();
} else if (id === 'rejection') {
Promise.resolve().then(rejectionStackFrame0);
}
});
});
});
function throwStackFrame0() {
throwStackFrame1();
}
function throwStackFrame1() {
throwStackFrame2();
}
function throwStackFrame2() {
throw new Error('This is an arbitrary error!');
}
function typeStackFrame0() {
typeStackFrame1();
}
function typeStackFrame1() {
typeStackFrame2();
}
function typeStackFrame2() {
const obj = {};
obj.method();
}
async function rejectionStackFrame0() {
return rejectionStackFrame1();
}
async function rejectionStackFrame1() {
return rejectionStackFrame2();
}
async function rejectionStackFrame2() {
throw new Error('This is an unhandled rejection!');
}
</script>
</head>
<body>
<div class="container">
<a href="https://www.bugsplat.com">
<img class="logo" src="./assets/bugsplat-logo.png" />
</a>
<div class="content">
<h1>Welcome to my-javascript-crasher!</h1>
<p>
This is a sample application that demonstrates
<a href="https://bugsplat.com" target="_blank">BugSplat</a> error
reporting for JavaScript based browser applications.
</p>
<div class="errors">
<h2>Errors</h2>
<button id="throw" class="error">
<h2>Error</h2>
<h4>Throw an arbitrary error</h4>
</button>
<button id="type" class="error">
<h2>Type Error</h2>
<h4>Call a function that doesn't exist</h4>
</button>
<button id="rejection" class="error">
<h2>Unhandled Rejection</h2>
<h4>Reject a promise without a catch</h4>
</button>
</div>
</div>
</div>
</body>
</html>