2021-09-14 09:57:06 -07:00
|
|
|
import Logger from '../libs/Logger';
|
|
|
|
|
|
|
|
|
|
class NativeException {
|
2022-06-06 14:59:53 +07:00
|
|
|
public process(): void {
|
|
|
|
|
process.on('uncaughtException', (exception) => {
|
2021-09-14 09:57:06 -07:00
|
|
|
Logger.log('critical', 'Critical error, cleaning up and exiting');
|
|
|
|
|
Logger.log('critical', exception.stack);
|
|
|
|
|
|
|
|
|
|
Logger.log('info', 'Clean up completed, exiting...');
|
|
|
|
|
process.exit(1);
|
|
|
|
|
});
|
|
|
|
|
|
2022-06-06 14:59:53 +07:00
|
|
|
process.on('unhandledRejection', (exception) => {
|
2021-09-14 09:57:06 -07:00
|
|
|
throw exception;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-06 14:59:53 +07:00
|
|
|
export default new NativeException();
|