Перехват неожиданных ошибок

This commit is contained in:
Mikhail Chechnev 2018-12-01 22:25:11 +03:00
parent 5657b62d15
commit fbc71f5138

View File

@ -57,6 +57,15 @@ process.on("SIGKILL", () => {
appSrv.stop();
});
//Перехват всех неохваченных ошибок
process.on("uncaughtException", e => {
//Протоколируем ошибку
if (e instanceof ServerError) appSrv.logger.error(e.sCode + ": " + e.sMessage);
else appSrv.logger.error(SERR_UNEXPECTED + ": " + e.message);
//Инициируем выход из процесса
appSrv.stop();
});
//Запуск сервера приложений
const start = async () => {
try {