From 1b0b0a22f94868fb6d3ca6b48ef1975cdfdd82e2 Mon Sep 17 00:00:00 2001 From: Isaac Date: Sun, 21 Jan 2024 02:30:47 +0000 Subject: [PATCH] fix: error handling (closes #506) --- src/lib/stats.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/stats.js b/src/lib/stats.js index 83a462c..5d58033 100644 --- a/src/lib/stats.js +++ b/src/lib/stats.js @@ -77,7 +77,13 @@ module.exports.sendToHouston = async client => { client.log.success('Posted client stats'); client.log.debug(res); } catch (res) { - client.log.error('An error occurred whilst posting stats:', (await res.json())?.error); + try { + const json = await res.json(); + client.log.error('An error occurred whilst posting stats:', json); + } catch (error) { + client.log.error('An error occurred whilst posting stats and the response couldn\'t be parsed'); + client.log.error(error.message); + } client.log.debug(res); } };