Skip to content

Commit b6489fe

Browse files
committed
PoolPlus: Make .defineTable() throw a TypeError (instead of Error) if name is not a string
1 parent 2ca6e43 commit b6489fe

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/PoolPlus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class PoolPlus extends Pool {
9292
*/
9393
defineTable(name, schema, migrationStrategy) {
9494
if (typeof name !== 'string') {
95-
throw new Error('The table name must be a string');
95+
throw new TypeError('The table name must be a string');
9696
}
9797
if (this._tables.has(name)) {
9898
throw new Error(`A table called "${name}" has already been defined for this pool`);

test/unit/PoolPlus.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ describe('PoolPlus', () => {
103103
});
104104

105105
it('should throw if the table name is not a string', () => {
106-
should.throws(() => pool.defineTable(/table/), /The table name must be a string/);
106+
(() => pool.defineTable(/table/)).should.throw(TypeError);
107+
(() => pool.defineTable(/table/)).should.throw(/The table name must be a string/);
107108
});
108109

109110
it('should throw if no columns are provided', () => {

0 commit comments

Comments
 (0)