Add unhandled rejection handler
This commit is contained in:
parent
005f28bd5a
commit
d89f167517
12
index.js
12
index.js
|
@ -9,7 +9,7 @@ const app = express();
|
||||||
global.log = log;
|
global.log = log;
|
||||||
|
|
||||||
const Discord = require("discord.js")
|
const Discord = require("discord.js")
|
||||||
const client = new Discord.Client({intents: ["Guilds", "DirectMessages", "MessageContent", "GuildMembers"]})
|
const client = new Discord.Client({ intents: ["Guilds", "DirectMessages", "MessageContent", "GuildMembers"] })
|
||||||
|
|
||||||
const pool = MariaDB.createPool({
|
const pool = MariaDB.createPool({
|
||||||
host: process.env.DB_HOST,
|
host: process.env.DB_HOST,
|
||||||
|
@ -96,6 +96,16 @@ client.on("messageCreate", async (message) => {
|
||||||
global.dmHandlers[message.author.id](message);
|
global.dmHandlers[message.author.id](message);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Global error handling for unhandled promise rejections and uncaught exceptions
|
||||||
|
process.on('unhandledRejection', (reason, promise) => {
|
||||||
|
log.error('Unhandled Rejection at:', promise, 'reason:', reason);
|
||||||
|
// Application specific logging, throwing an error, or other logic here
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('uncaughtException', (error) => {
|
||||||
|
log.error('Uncaught Exception thrown:', error);
|
||||||
|
// Application specific logging, throwing an error, or other logic here
|
||||||
|
});
|
||||||
|
|
||||||
const port = process.env.SERVER_PORT || 3000;
|
const port = process.env.SERVER_PORT || 3000;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue