Skip to content

Commit

Permalink
Fix error message for invalid index specifications.
Browse files Browse the repository at this point in the history
  • Loading branch information
autopulated committed Apr 24, 2024
1 parent 1744d25 commit c22c2da
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const parseIndexSpecification = (index, schemaSource) => {
sortKey = indexSpec.sortKey;
}
} else {
throw new Error('Invalid index specification ${indexSpec}: must be 1,true, or {hashKey:"", sortKey?:""}.');
throw new Error(`Invalid index specification ${JSON.stringify(indexSpec)}: must be 1, true, or {hashKey:"", sortKey?:""}.`);
}
indices.push({
index,
Expand Down
2 changes: 1 addition & 1 deletion test/schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ t.test('schema errors', async t => {
aaa: false
}
});
}, {message: 'Invalid index specification ${indexSpec}: must be 1,true, or {hashKey:"", sortKey?:""}.'} , 'should throw with key:false');
}, {message: 'Invalid index specification false: must be 1, true, or {hashKey:"", sortKey?:""}.'}, 'should throw with key:false');

t.throws(() => {
DynamoDM.Schema('namespace.shouldthrow', {
Expand Down

0 comments on commit c22c2da

Please sign in to comment.