From b1911cada6fb6d64fa413200da40957d1c51e474 Mon Sep 17 00:00:00 2001 From: Felix Hildebrandt Date: Fri, 22 Mar 2024 11:21:45 +0100 Subject: [PATCH] update error messages with code styling --- src/lib/utils.test.ts | 4 ++-- src/lib/utils.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/utils.test.ts b/src/lib/utils.test.ts index d6d9ae75..27a75b2a 100644 --- a/src/lib/utils.test.ts +++ b/src/lib/utils.test.ts @@ -785,7 +785,7 @@ describe('utils', () => { assert.throws( encodeDataWithNegativeStartingIndex, - /Invalid startingIndex/, + /Invalid `startingIndex`/, 'Should throw an error for negative startingIndex', ); }); @@ -810,7 +810,7 @@ describe('utils', () => { assert.throws( encodeDataWithLowerTotalArrayLength, - /Invalid totalArrayLength/, + /Invalid `totalArrayLength`/, 'Should throw an error for totalArrayLength smaller than the number of provided elements', ); }); diff --git a/src/lib/utils.ts b/src/lib/utils.ts index d7bbb4a7..a447f0b0 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -267,19 +267,19 @@ export function encodeKey( typeof totalArrayLength !== 'number' ) { throw new Error( - 'Invalid startingIndex or totalArrayLength parameters. Values must be of type number.', + 'Invalid `startingIndex` or `totalArrayLength` parameters. Values must be of type number.', ); } if (startingIndex < 0) { throw new Error( - 'Invalid startingIndex parameter. Value cannot be negative.', + 'Invalid `startingIndex` parameter. Value cannot be negative.', ); } if (totalArrayLength < value.length) { throw new Error( - 'Invalid totalArrayLength parameter. Array length must be at least as large as the number of elements of the value array.', + 'Invalid `totalArrayLength` parameter. Array length must be at least as large as the number of elements of the value array.', ); }