From 67730845a5003ed90e75239556e4f0dcca8281be Mon Sep 17 00:00:00 2001 From: Killer Boss Original <73131550+killerbossoriginal@users.noreply.github.com> Date: Tue, 5 Jul 2022 16:09:45 +0200 Subject: [PATCH] . --- index.js | 24 ++++++++++++++++++++++++ package.json | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 09b3742..c3c1d07 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,30 @@ client.config = require('./config.js').settings; const MapDB = require('quickmap.db'); const db = new MapDB('database.json'); +const chalk = require('chalk') + +function catchError(message, err, origin, reason) { + console.log(chalk.gray('—————————————————————————————————')); + console.log( + chalk.white('['), + chalk.red.bold('AntiCrash'), + chalk.white(']'), + chalk.gray(' : '), + chalk.white.bold(message), + ); + console.log(chalk.gray('—————————————————————————————————')); + console.log(err, origin, reason); +} + +process.on('unhandledRejection', (err, origin) => { + catchError('Unhandled Rejection/Catch', err, origin); +}); +process.on('uncaughtException', (err, origin) => { + catchError('Uncaught Exception/Catch', err, origin); +}); +process.on('multipleResolves', (type, promise, reason) => { + catchError('Multiple Resolves', type, promise, reason); +}); async function setup() { var isset = await db.get('client.issetupped') diff --git a/package.json b/package.json index 9ebca2d..cd85723 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "cors": "^2.8.5", "express": "^4.18.1", "fs": "^0.0.1-security", - "quickmap.db": "^1.1.1" + "quickmap.db": "^1.0.6", + "chalk": "^4.1.2" } } \ No newline at end of file