From 9820f57c64bc5d8972219fd27d4c6f0aac153855 Mon Sep 17 00:00:00 2001 From: Matt Visnovsky Date: Thu, 13 Jun 2024 12:10:28 -0600 Subject: [PATCH] Truncate long responses --- src/util.js | 1 + src/util.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/util.js b/src/util.js index c0c6a6d2..eeadf01a 100644 --- a/src/util.js +++ b/src/util.js @@ -444,6 +444,7 @@ async function evaluateJsonQuery(data, jsonPath, jsonPathOperator, expectedValue }; } catch (err) { + response = (response.toString().length > 50) ? `${response.substring(0, 50)}… (truncated)` : response.toString(); throw new Error(`Error evaluating JSON query: ${err.message}. Response from server was: ${response}`); } } diff --git a/src/util.ts b/src/util.ts index 24a03f58..37b080bb 100644 --- a/src/util.ts +++ b/src/util.ts @@ -709,6 +709,7 @@ export async function evaluateJsonQuery(data: any, jsonPath: string, jsonPathOpe response // The response from the server or result from initial json-query evaluation }; } catch (err: any) { + response = (response.toString().length > 50) ? `${response.substring(0, 50)}… (truncated)` : response.toString();// Truncate long responses to the console throw new Error(`Error evaluating JSON query: ${err.message}. Response from server was: ${response}`); } }