Skip to content

Commit 7da31ec

Browse files
committed
Move unhandled error/rejection tracking to root app
1 parent 4094ba3 commit 7da31ec

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

app/discord/gateway.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,4 @@ export default function init() {
5252
};
5353

5454
client.on("error", errorHandler);
55-
process.on("uncaughtException", errorHandler);
56-
process.on("unhandledRejection", errorHandler);
5755
}

app/index.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ const app = express();
88

99
app.use(express.static(path.join(__dirname, "..", "public")));
1010

11-
app.get("/butts", (req, res) => {
12-
res.send("butts");
13-
});
11+
/**
12+
Route handlers and static hosting
13+
*/
14+
15+
app.use(express.static(path.join(__dirname, "..", "public")));
1416

1517
// needs to handle all verbs (GET, POST, etc.)
1618
app.all(
@@ -32,3 +34,15 @@ app.all(
3234
app.listen(process.env.PORT || "3000");
3335

3436
discordBot();
37+
38+
const errorHandler = (error: unknown) => {
39+
Sentry.captureException(error);
40+
if (error instanceof Error) {
41+
console.log("ERROR", error.message);
42+
} else if (typeof error === "string") {
43+
console.log("ERROR", error);
44+
}
45+
};
46+
47+
process.on("uncaughtException", errorHandler);
48+
process.on("unhandledRejection", errorHandler);

0 commit comments

Comments
 (0)