Skip to content

Commit

Permalink
update error messages with code styling
Browse files Browse the repository at this point in the history
  • Loading branch information
fhildeb committed Mar 22, 2024
1 parent 7270593 commit b1911ca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/lib/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ describe('utils', () => {

assert.throws(
encodeDataWithNegativeStartingIndex,
/Invalid startingIndex/,
/Invalid `startingIndex`/,
'Should throw an error for negative startingIndex',
);
});
Expand All @@ -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',
);
});
Expand Down
6 changes: 3 additions & 3 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
);
}

Expand Down

0 comments on commit b1911ca

Please sign in to comment.