From 75116826c18513ea094fc6cb26b454f2a3b5bb42 Mon Sep 17 00:00:00 2001 From: Seth Stone <281819+sethstone@users.noreply.github.com> Date: Sun, 31 Aug 2025 16:42:35 -0500 Subject: [PATCH] Prevent crash if serialization for debugging fails. Also, corrects syntax for JSON.stringify() --- lib/apicontrollersbase.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/apicontrollersbase.js b/lib/apicontrollersbase.js index 613b51a..0f1f702 100644 --- a/lib/apicontrollersbase.js +++ b/lib/apicontrollersbase.js @@ -89,7 +89,11 @@ class APIOperationBase { var obj = this; - logger.debug(JSON.stringify(this._request, 2, null)); + try { + logger.debug(JSON.stringify(this._request, null, 2)); + } catch (e) { + logger.debug('Could not stringify request:', e.message); + } var axiosConfig = { baseURL: this._endpoint, @@ -107,7 +111,7 @@ class APIOperationBase { axios.request(axiosConfig).then((response) => { if (typeof response.data !== 'undefined') { var responseObj = JSON.parse(JSON.stringify(response.data)); - logger.debug(JSON.stringify(responseObj, 2, null)); + logger.debug(JSON.stringify(responseObj, null, 2)); obj._response = responseObj; callback(); } else {