Explorar o código

Write to error log on unhandled rejection/exception

Simon Detheridge %!s(int64=6) %!d(string=hai) anos
pai
achega
6e19a650d2
Modificáronse 1 ficheiros con 9 adicións e 0 borrados
  1. 9 0
      services/filestore/app.js

+ 9 - 0
services/filestore/app.js

@@ -156,4 +156,13 @@ if (!module.parent) {
   })
 }
 
+process
+  .on('unhandledRejection', (reason, p) => {
+    logger.err(reason, 'Unhandled Rejection at Promise', p)
+  })
+  .on('uncaughtException', err => {
+    logger.err(err, 'Uncaught Exception thrown')
+    process.exit(1)
+  })
+
 module.exports = app