DEV Community

Kazi Abdur Rakib
Kazi Abdur Rakib

Posted on

AppError UnhandledRejection _ UncaughtException

///src/app.ts
const test = async (req: Request, res: Response) => {
  Promise.reject();
  // res.send('Hello PH UNIVERSTIY');
};

Enter fullscreen mode Exit fullscreen mode
//src/server.ts
process.on('unhandledRejection', () => {
  console.log(`😈 unahandledRejection is detected , shutting down ...`);
  if (server) {
    server.close(() => {
      process.exit(1);
    });
  }
  process.exit(1);
});

process.on('uncaughtException', () => {
  console.log(`😈 uncaughtException is detected , shutting down ...`);
  process.exit(1);
});
Enter fullscreen mode Exit fullscreen mode

Top comments (0)