mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-09-01 22:55:24 +00:00
console.error unhandled errors
This commit is contained in:
3
index.js
3
index.js
@@ -3,6 +3,7 @@ require('dotenv').config();
|
|||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
const { deleteAfter } = require('./utils/tg');
|
const { deleteAfter } = require('./utils/tg');
|
||||||
|
const { logErrorProperly } = require('./utils/log');
|
||||||
|
|
||||||
// Bot
|
// Bot
|
||||||
const bot = require('./bot');
|
const bot = require('./bot');
|
||||||
@@ -48,4 +49,6 @@ bot.command('report', reportHandler);
|
|||||||
bot.hears(/^@admins?$/i, reportHandler);
|
bot.hears(/^@admins?$/i, reportHandler);
|
||||||
bot.command('staff', staffHandler);
|
bot.command('staff', staffHandler);
|
||||||
|
|
||||||
|
bot.catch(logErrorProperly);
|
||||||
|
|
||||||
bot.startPolling();
|
bot.startPolling();
|
||||||
|
@@ -5,10 +5,13 @@ const { inspect } = require('util');
|
|||||||
const logError = log => err =>
|
const logError = log => err =>
|
||||||
log && console.error(`${err.name}: ${err.message}`);
|
log && console.error(`${err.name}: ${err.message}`);
|
||||||
|
|
||||||
|
const logErrorProperly = err => console.error(err);
|
||||||
|
|
||||||
const print = value =>
|
const print = value =>
|
||||||
console.log(inspect(value, { colors: true, depth: null }));
|
console.log(inspect(value, { colors: true, depth: null }));
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
logError,
|
logError,
|
||||||
|
logErrorProperly,
|
||||||
print
|
print
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user