From be8524f5b7f7d7bb797131594f4be74655e0f22d Mon Sep 17 00:00:00 2001 From: Yuzu Date: Tue, 14 Sep 2021 09:57:06 -0700 Subject: [PATCH] Create NativeException.ts --- src/exception/NativeException.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/exception/NativeException.ts diff --git a/src/exception/NativeException.ts b/src/exception/NativeException.ts new file mode 100644 index 0000000..83a2cbf --- /dev/null +++ b/src/exception/NativeException.ts @@ -0,0 +1,27 @@ +import Logger from '../libs/Logger'; + +import App from '../providers/App'; + +class NativeException { + + + public process (): void { + + process.on('uncaughtException', exception => { + Logger.log('critical', 'Critical error, cleaning up and exiting'); + Logger.log('critical', exception.stack); + + Logger.log('info', 'Clean up completed, exiting...'); + process.exit(1); + }); + + process.on('unhandledRejection', exception => { + throw exception; + }); + + } + + +} + +export default new NativeException; \ No newline at end of file