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