abstract errorhandle

v2
Kit Kasune 2 years ago
parent 00af710ebd
commit c1d40eb1be
  1. 5
      bot.js
  2. 8
      src/util/log/errorhandler.js

@ -3,6 +3,7 @@ const Discord = require('discord.js');
const auth = require('./src/json/auth.json'); const auth = require('./src/json/auth.json');
const config = require('./src/json/config.json'); const config = require('./src/json/config.json');
const randresp = require('./src/json/randresp.json'); const randresp = require('./src/json/randresp.json');
const errorhandler = require('./src/util/log/errorhandler');
const log = require('./src/util/log/log'); const log = require('./src/util/log/log');
@ -27,9 +28,7 @@ const startBot = async () => {
await require('./src/handle/startup/run/login')(client); //log in to discord await require('./src/handle/startup/run/login')(client); //log in to discord
await require('./src/db/connect')(client); //connect to database await require('./src/db/connect')(client); //connect to database
}; };
startBot().catch(() => { startBot().catch(e => errorhandler(e)); // TODO add a .catch() and flag to recover the process
console.log("\nWell this is awkward.\n");
}); // TODO add a .catch() and flag to recover the process
// feels like there isn't a function name to do this justice :joy: // feels like there isn't a function name to do this justice :joy:
// to do list: // to do list:

@ -0,0 +1,8 @@
const chalk = require('chalk');
module.exports = e => {
console.log(`#######################################\n\n${chalk.grey('[NATS]')} >> ${chalk.hex('#78d9f8')("Well this is awkward.")}\n`);
console.log(`${chalk.bold.redBright.underline("There was an error that killed Natsuki's process.")}\n${chalk.redBright("See available stack trace and error information below.")}\n`);
console.error(e);
console.log(`\n#######################################\n\n${chalk.grey('[NATS]')} >> ${chalk.hex('#78d9f8')("Back to sleepies...")}`);
};
Loading…
Cancel
Save