Skip to content

Commit

Permalink
PoolPlus: Make .defineTable() throw a TypeError (instead of Error) …
Browse files Browse the repository at this point in the history
…if name is not a string
  • Loading branch information
nwoltman committed Apr 5, 2017
1 parent 2ca6e43 commit b6489fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/PoolPlus.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class PoolPlus extends Pool {
*/
defineTable(name, schema, migrationStrategy) {
if (typeof name !== 'string') {
throw new Error('The table name must be a string');
throw new TypeError('The table name must be a string');
}
if (this._tables.has(name)) {
throw new Error(`A table called "${name}" has already been defined for this pool`);
Expand Down
3 changes: 2 additions & 1 deletion test/unit/PoolPlus.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ describe('PoolPlus', () => {
});

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

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

0 comments on commit b6489fe

Please sign in to comment.