Commit 58ab2ad84595ee57951ce16514062484e5e8200b

Authored by Adhidarma Hadiwinoto
1 parent 6048a97ff3
Exists in master and in 1 other branch dev

Error handling on can not listen partner request

Showing 1 changed file with 4 additions and 6 deletions Side-by-side Diff

lib/listener-partner/index.js
... ... @@ -21,11 +21,9 @@ app.use((req, res) => {
21 21 res.status(404).end('404: Method not found.');
22 22 });
23 23  
24   -app.listen(config.listener.partner.port || DEFAULT_LISTENER_FROM_PARTNER_PORT, (err) => {
25   - if (err) {
26   - logger.warn(`Can not listen request from partner on port ${config.listener.partner.port || DEFAULT_LISTENER_FROM_PARTNER_PORT}`);
27   - process.exit(1);
28   - }
29   -
  24 +app.listen(config.listener.partner.port || DEFAULT_LISTENER_FROM_PARTNER_PORT, () => {
30 25 logger.info(`Listen from partner request on port ${config.listener.partner.port}`);
  26 +}).on('error', (e) => {
  27 + logger.error(`Can not listen request from partner on port ${config.listener.partner.port || DEFAULT_LISTENER_FROM_PARTNER_PORT}. ${e.toString()}`);
  28 + process.exit(1);
31 29 });