Skip to content

Commit

Permalink
Add a global uncaughtException handler on the server
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxLeiter committed Apr 28, 2022
1 parent 32327b4 commit bc1d6aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/plugins/inputs/who.js
Expand Up @@ -59,7 +59,7 @@ exports.input = function ({irc}, chan, cmd, args) {
// This has the added benefit of easily showing it in the same buffer
// as the WHO command.
irc.who(args[0], (event) => {
if (!event.users?.length) {
if (!event.users.length) {
chan.pushMessage(
this,
new Msg({
Expand Down
7 changes: 7 additions & 0 deletions src/server.js
Expand Up @@ -239,6 +239,13 @@ module.exports = function (options = {}) {

process.on("SIGINT", exitGracefully);
process.on("SIGTERM", exitGracefully);
process.on("uncaughtException", (err) => {
// eslint-disable-next-line no-console
console.error(
`An uncaught exception occured. Please report this to the developers.\n`,
err.message + "\n" + err.stack
);
});

// Clear storage folder after server starts successfully
if (Helper.config.prefetchStorage) {
Expand Down

0 comments on commit bc1d6aa

Please sign in to comment.