diff --git a/lib/schema.js b/lib/schema.js index ea0d228..eb3695d 100644 --- a/lib/schema.js +++ b/lib/schema.js @@ -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, diff --git a/test/schemas.js b/test/schemas.js index 23c262e..64b3a92 100644 --- a/test/schemas.js +++ b/test/schemas.js @@ -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', {