From 9daee58bf4d6200e15322b5c3f4f4b75390cf142 Mon Sep 17 00:00:00 2001 From: Chang-Hung Liang Date: Tue, 31 Mar 2020 13:58:02 +0800 Subject: [PATCH] fix(core): more clear curlies type error --- packages/core/src/tools/cleaner.js | 8 +++++--- packages/core/test/create-request-client.js | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/core/src/tools/cleaner.js b/packages/core/src/tools/cleaner.js index c50147614..0734a9980 100644 --- a/packages/core/src/tools/cleaner.js +++ b/packages/core/src/tools/cleaner.js @@ -77,10 +77,12 @@ const recurseReplaceBank = (obj, bank = {}) => { (Array.isArray(replacementValue) || _.isPlainObject(replacementValue)); if (shouldThrowTypeError) { + const bareKey = _.trimEnd(_.trimStart(key, '{'), '}'); throw new TypeError( - `Cannot reliably interpolate objects or arrays into a string. We received an ${getObjectType( - replacementValue - )}:\n"${replacementValue}"` + 'Cannot reliably interpolate objects or arrays into a string. ' + + `Variable \`${bareKey}\` is an ${getObjectType( + replacementValue + )}:\n"${replacementValue}"` ); } diff --git a/packages/core/test/create-request-client.js b/packages/core/test/create-request-client.js index aeecdfb66..41235c0b8 100644 --- a/packages/core/test/create-request-client.js +++ b/packages/core/test/create-request-client.js @@ -713,7 +713,8 @@ describe('request client', () => { message: 'No arrays, thank you: {{bundle.inputData.badData}}' } }).should.be.rejectedWith( - 'Cannot reliably interpolate objects or arrays into a string. We received an Array:\n"1,2,3"' + 'Cannot reliably interpolate objects or arrays into a string. ' + + 'Variable `bundle.inputData.badData` is an Array:\n"1,2,3"' ); });