add error handling for unhandled rejections and uncaught exceptions
This commit is contained in:
parent
d2af03764b
commit
eaa505bfb1
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "denim_3001",
|
||||
"version": "3001.62.4",
|
||||
"version": "3001.62.5",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "denim_3001",
|
||||
"version": "3001.62.4",
|
||||
"version": "3001.62.5",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@discordjs/voice": "^0.18.0",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "denim_3001",
|
||||
"version": "3001.62.4",
|
||||
"version": "3001.62.5",
|
||||
"description": "Toto je velmi kvalitní bot.",
|
||||
"repository": {
|
||||
"url": "https://github.com/Histmy/Denim-Bot/"
|
||||
|
||||
31
src/app.ts
31
src/app.ts
@ -29,6 +29,37 @@ client.on("shardError", err => {
|
||||
adminLog(client, "šárd ejrr??", err);
|
||||
});
|
||||
|
||||
process.on("unhandledRejection", (reason, promise) => {
|
||||
log(new Error("Unhandled Rejection:"), reason, promise);
|
||||
|
||||
let message: string | Error;
|
||||
|
||||
if (reason instanceof Error) {
|
||||
message = reason;
|
||||
} else if (typeof reason == "string") {
|
||||
message = reason;
|
||||
} else {
|
||||
message = String(reason);
|
||||
}
|
||||
|
||||
adminLog(client, "Unhandled Rejection", message);
|
||||
});
|
||||
|
||||
process.on("uncaughtException", (err) => {
|
||||
log(new Error("Uncaught Exception:"), err);
|
||||
|
||||
let message: string | Error;
|
||||
if (err instanceof Error) {
|
||||
message = err;
|
||||
} else if (typeof err == "string") {
|
||||
message = err;
|
||||
} else {
|
||||
message = String(err);
|
||||
}
|
||||
|
||||
adminLog(client, "Uncaught Exception", message);
|
||||
});
|
||||
|
||||
client.komandy = {};
|
||||
client.aliasy = {};
|
||||
setClient(client);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user