Skip to content

Commit fff463e

Browse files
committed
improvement: Improve error messages when creating ColumnDefinitions with improper arguments
Avoid using the "you" pronoun.
1 parent dc15b89 commit fff463e

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/ColumnDefinitions/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ const ColumnDefinitions = {
7777
return new TextColumnDefinition('char', m);
7878
},
7979
varchar(m) {
80-
if (m === null || m === undefined) {
81-
throw new Error('You must specify the `m` argument for varchar');
80+
if (m === undefined) {
81+
throw new Error('The varchar `m` argument must be specified');
8282
}
8383
return new TextColumnDefinition('varchar', m);
8484
},
@@ -98,8 +98,8 @@ const ColumnDefinitions = {
9898
return new ColumnDefinition('binary', m);
9999
},
100100
varbinary(m) {
101-
if (m === null || m === undefined) {
102-
throw new Error('You must specify the `m` argument for varbinary');
101+
if (m === undefined) {
102+
throw new Error('The varbinary `m` argument must be specified');
103103
}
104104
return new ColumnDefinition('varbinary', m);
105105
},
@@ -117,13 +117,13 @@ const ColumnDefinitions = {
117117
},
118118
enum(...values) {
119119
if (values.length === 0) {
120-
throw new Error('You must provide at least one possible enum value');
120+
throw new Error('At least one enum value must be provided');
121121
}
122122
return new TextColumnDefinition('enum', values);
123123
},
124124
set(...values) {
125125
if (values.length === 0) {
126-
throw new Error('You must provide at least one possible set value');
126+
throw new Error('At least one set value must be provided');
127127
}
128128
return new TextColumnDefinition('set', values);
129129
},

test/unit/ColumnDefinitions.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,8 @@ describe('ColumnDefinitions', () => {
547547
describe('varchar and varbinary', () => {
548548

549549
it('should throw if no `m` value is provided when creating the column definition', () => {
550-
should.throws(() => ColumnDefinitions.varchar(), /You must specify the `m` argument for varchar/);
551-
should.throws(() => ColumnDefinitions.varbinary(), /You must specify the `m` argument for varbinary/);
550+
should.throws(() => ColumnDefinitions.varchar(), 'The varchar `m` argument must be specified');
551+
should.throws(() => ColumnDefinitions.varbinary(), 'The varbinary `m` argument must be specified');
552552
});
553553

554554
it('should accept 0 as a valid `m` value', () => {
@@ -576,8 +576,8 @@ describe('ColumnDefinitions', () => {
576576
});
577577

578578
it('should throw if no values are provided when creating the column definition', () => {
579-
should.throws(() => ColumnDefinitions.enum(), /provide at least one possible enum value/);
580-
should.throws(() => ColumnDefinitions.set(), /provide at least one possible set value/);
579+
should.throws(() => ColumnDefinitions.enum(), 'At least one enum value must be provided');
580+
should.throws(() => ColumnDefinitions.set(), 'At least one set value must be provided');
581581
});
582582

583583
});

0 commit comments

Comments
 (0)