Skip to content

Commit f0ca418

Browse files
committed
ImageViewer & JetSnack: log unhandled errors
1 parent ea32179 commit f0ca418

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

wasm/iv/index.html

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,13 @@
148148
</body>
149149

150150
<script type="application/javascript" >
151-
const unhandledError = (event, error) => {
151+
const unhandledError = (event, error, type) => {
152+
goatcounter.count({
153+
path: (p) => `#${type}-${p}`,
154+
title: `${error.name}: ${error.message}`,
155+
event: true,
156+
})
157+
152158
if (error instanceof WebAssembly.CompileError) {
153159
document.getElementById("warning").style.display="initial";
154160

@@ -157,9 +163,8 @@
157163
if (webpackOverlay != null) webpackOverlay.style.display="none";
158164
}
159165
}
160-
addEventListener("error", (event) => unhandledError(event, event.error));
161-
addEventListener("unhandledrejection", (event) => unhandledError(event, event.reason));
162-
166+
addEventListener("error", (event) => unhandledError(event, event.error, "Err"));
167+
addEventListener("unhandledrejection", (event) => unhandledError(event, event.reason, "UR"));
163168
</script>
164169

165170
<!-- Track visits with respect to privacy -->

wasm/jetsnack/index.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,13 @@
151151
</body>
152152

153153
<script type="application/javascript" >
154-
const unhandledError = (event, error) => {
154+
const unhandledError = (event, error, type) => {
155+
goatcounter.count({
156+
path: (p) => `#${type}-${p}`,
157+
title: `${error.name}: ${error.message}`,
158+
event: true,
159+
})
160+
155161
if (error instanceof WebAssembly.CompileError) {
156162
document.getElementById("warning").style.display="initial";
157163

@@ -160,8 +166,8 @@
160166
if (webpackOverlay != null) webpackOverlay.style.display="none";
161167
}
162168
}
163-
addEventListener("error", (event) => unhandledError(event, event.error));
164-
addEventListener("unhandledrejection", (event) => unhandledError(event, event.reason));
169+
addEventListener("error", (event) => unhandledError(event, event.error, "Err"));
170+
addEventListener("unhandledrejection", (event) => unhandledError(event, event.reason, "UR"));
165171
</script>
166172

167173
<!-- Track visits with respect to privacy -->

0 commit comments

Comments
 (0)