From 818c3e116bc5fc64c0c3e4c745238fba03f88ef9 Mon Sep 17 00:00:00 2001 From: Ayushya Amitabh Date: Mon, 10 Aug 2020 16:28:26 -0400 Subject: [PATCH] v1.6.0/lifecycle ask catch error --- functions/webhooks/ask.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/functions/webhooks/ask.js b/functions/webhooks/ask.js index 8cfcee0..08521eb 100644 --- a/functions/webhooks/ask.js +++ b/functions/webhooks/ask.js @@ -1,5 +1,9 @@ module.exports = async (req, res) => { - const { question, answer } = JSON.parse(req.body); - console.info(`[RECEIVED]\tWEBHOOKS/ASK\tQ:${question}\tA:${answer}`); - res.status(200).send({ message: 'Got answer.' }); + try { + const { question, answer } = JSON.parse(req.body); + console.info(`[RECEIVED]\tWEBHOOKS/ASK\tQ:${question}\tA:${answer}`); + res.status(200).send({ message: "Got answer." }); + } catch (e) { + console.info(`[ERROR]\tWEBHOOKS/ASK/Failed To Parse\tBody:${req.body}`); + } };