Add API error handling mechanism (#14)

This commit is contained in:
shweelan authored and Zaid Abdulla committed 2018-12-26 00:22:07 -08:00
1 parent ad3dfeae7f
commit f48b596271
1 file changed
+8
+8
View File
@@ -52,6 +52,10 @@ function getPermissionSets(roles) {
return permissionSets; return permissionSets;
} }
koa.on("error", async err => {
throw err;
});
koa.use( koa.use(
koaJwt({ koaJwt({
secret: JWT_SECRET, secret: JWT_SECRET,
@@ -179,6 +183,10 @@ function exit() {
}); });
} }
process.on("unhandledRejection", err => {
throw err;
});
process.on("uncaughtException", err => { process.on("uncaughtException", err => {
logger.error({ logger.error({
message: "Uncaught exception", message: "Uncaught exception",