From 3e344ceca2d7d771532343c852b57d3560b87294 Mon Sep 17 00:00:00 2001 From: GingerPlusPlus Date: Sun, 24 Sep 2017 18:34:32 +0200 Subject: [PATCH] console.error unhandled errors --- index.js | 3 +++ utils/log.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/index.js b/index.js index 08a31b3..ecc4813 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,7 @@ require('dotenv').config(); // Utils const { deleteAfter } = require('./utils/tg'); +const { logErrorProperly } = require('./utils/log'); // Bot const bot = require('./bot'); @@ -48,4 +49,6 @@ bot.command('report', reportHandler); bot.hears(/^@admins?$/i, reportHandler); bot.command('staff', staffHandler); +bot.catch(logErrorProperly); + bot.startPolling(); diff --git a/utils/log.js b/utils/log.js index 4460551..0d40bfd 100644 --- a/utils/log.js +++ b/utils/log.js @@ -5,10 +5,13 @@ const { inspect } = require('util'); const logError = log => err => log && console.error(`${err.name}: ${err.message}`); +const logErrorProperly = err => console.error(err); + const print = value => console.log(inspect(value, { colors: true, depth: null })); module.exports = { logError, + logErrorProperly, print };