Skip to content

Commit edad4e0

Browse files
committed
Format error messages
1 parent f58749a commit edad4e0

File tree

39 files changed

+158
-128
lines changed

39 files changed

+158
-128
lines changed

lib/node_modules/@stdlib/_tools/bib/citation-reference/lib/validate.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var isObject = require( '@stdlib/assert/is-plain-object' );
2424
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
2525
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
26+
var format = require( '@stdlib/string/format' );
2627

2728

2829
// MAIN //
@@ -51,19 +52,18 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
5152
*/
5253
function validate( opts, options ) {
5354
if ( !isObject( options ) ) {
54-
return new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options +
55-
'`.' );
55+
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
5656
}
5757
if ( hasOwnProp( options, 'database' ) ) {
5858
opts.database = options.database;
5959
if ( !isString( opts.database ) ) {
60-
return new TypeError( 'invalid option. `database` option must be a primitive string. Option: `' + opts.database + '`.' );
60+
return new TypeError( format( 'invalid option. `%s` option must be a string primitive. Option: `%s`.', 'database', opts.database ) );
6161
}
6262
}
6363
if ( hasOwnProp( options, 'csl' ) ) {
6464
opts.csl = options.csl;
6565
if ( !isString( opts.csl ) ) {
66-
return new TypeError( 'invalid option. `csl` option must be a primitive string. Option: `' + opts.csl + '`.' );
66+
return new TypeError( format( 'invalid option. `%s` option must be a string primitive. Option: `%s`.', 'csl', opts.csl ) );
6767
}
6868
}
6969
return null;

lib/node_modules/@stdlib/_tools/github/set-topics/lib/validate.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
2424
var isObject = require( '@stdlib/assert/is-object' );
2525
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
26+
var format = require( '@stdlib/string/format' );
2627

2728

2829
// MAIN //
@@ -38,16 +39,16 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
3839
*/
3940
function validate( opts, options ) {
4041
if ( !isObject( options ) ) {
41-
return new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options + '`.' );
42+
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
4243
}
4344
opts.token = options.token;
4445
if ( !isString( opts.token ) ) {
45-
return new TypeError( 'invalid option. `token` option must be a string primitive. Option: `' + opts.token + '`.' );
46+
return new TypeError( format( 'invalid option. `%s` option must be a string primitive. Option: `%s`.', 'token', opts.token ) );
4647
}
4748
if ( hasOwnProp( options, 'useragent' ) ) {
4849
opts.useragent = options.useragent;
4950
if ( !isString( opts.useragent ) ) {
50-
return new TypeError( 'invalid option. `useragent` option must be a string primitive. Option: `' + opts.useragent + '`.' );
51+
return new TypeError( format( 'invalid option. `%s` option must be a string primitive. Option: `%s`.', 'useragent', opts.useragent ) );
5152
}
5253
}
5354
return null;

lib/node_modules/@stdlib/_tools/github/star-repo/lib/validate.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
2424
var isObject = require( '@stdlib/assert/is-object' );
2525
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
26+
var format = require( '@stdlib/string/format' );
2627

2728

2829
// MAIN //
@@ -38,16 +39,16 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
3839
*/
3940
function validate( opts, options ) {
4041
if ( !isObject( options ) ) {
41-
return new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options + '`.' );
42+
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
4243
}
4344
opts.token = options.token;
4445
if ( !isString( opts.token ) ) {
45-
return new TypeError( 'invalid option. `token` option must be a string primitive. Option: `' + opts.token + '`.' );
46+
return new TypeError( format( 'invalid option. `%s` option must be a string primitive. Option: `%s`.', 'token', opts.token ) );
4647
}
4748
if ( hasOwnProp( options, 'useragent' ) ) {
4849
opts.useragent = options.useragent;
4950
if ( !isString( opts.useragent ) ) {
50-
return new TypeError( 'invalid option. `useragent` option must be a string primitive. Option: `' + opts.useragent + '`.' );
51+
return new TypeError( format( 'invalid option. `%s` option must be a string primitive. Option: `%s`.', 'useragent', opts.useragent ) );
5152
}
5253
}
5354
return null;

lib/node_modules/@stdlib/_tools/licenses/licenses/lib/validate.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var hasOwnProp = require( '@stdlib/assert/has-own-property' );
2525
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2626
var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
2727
var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive;
28+
var format = require( '@stdlib/string/format' );
2829

2930

3031
// MAIN //
@@ -53,25 +54,24 @@ var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).is
5354
*/
5455
function validate( opts, options ) {
5556
if ( !isObject( options ) ) {
56-
return new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options +
57-
'`.' );
57+
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
5858
}
5959
if ( hasOwnProp( options, 'dir' ) ) {
6060
opts.dir = options.dir;
6161
if ( !isString( opts.dir ) ) {
62-
return new TypeError( 'invalid option. `dir` option must be a primitive string. Option: `' + opts.dir + '`.' );
62+
return new TypeError( format( 'invalid option. `%s` option must be a string primitive. Option: `%s`.', 'dir', opts.dir ) );
6363
}
6464
}
6565
if ( hasOwnProp( options, 'depth' ) ) {
6666
opts.depth = options.depth;
6767
if ( !isNonNegativeInteger( opts.depth ) ) {
68-
return new TypeError( 'invalid option. `depth` option must be a nonnegative integer. Option: `' + opts.depth + '`.' );
68+
return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'depth', opts.depth ) );
6969
}
7070
}
7171
if ( hasOwnProp( options, 'dev' ) ) {
7272
opts.dev = options.dev;
7373
if ( !isBoolean( opts.dev ) ) {
74-
return new TypeError( 'invalid option. `dev` option must be a primitive boolean. Option: `' + opts.dev + '`.' );
74+
return new TypeError( format( 'invalid option. `%s` option must be a boolean primitive. Option: `%s`.', 'dev', opts.dev ) );
7575
}
7676
}
7777
return null;

lib/node_modules/@stdlib/_tools/links/id2uri/lib/validate.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var isObject = require( '@stdlib/assert/is-plain-object' );
2424
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
2525
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
26+
var format = require( '@stdlib/string/format' );
2627

2728

2829
// MAIN //
@@ -49,13 +50,12 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
4950
*/
5051
function validate( opts, options ) {
5152
if ( !isObject( options ) ) {
52-
return new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options +
53-
'`.' );
53+
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
5454
}
5555
if ( hasOwnProp( options, 'database' ) ) {
5656
opts.database = options.database;
5757
if ( !isString( opts.database ) ) {
58-
return new TypeError( 'invalid option. `database` option must be a primitive string. Option: `' + opts.database + '`.' );
58+
return new TypeError( format( 'invalid option. `%s` option must be a string primitive. Option: `%s`.', 'database', opts.database ) );
5959
}
6060
}
6161
return null;

lib/node_modules/@stdlib/_tools/links/uri2id/lib/validate.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var isObject = require( '@stdlib/assert/is-plain-object' );
2424
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
2525
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
26+
var format = require( '@stdlib/string/format' );
2627

2728

2829
// MAIN //
@@ -49,13 +50,12 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
4950
*/
5051
function validate( opts, options ) {
5152
if ( !isObject( options ) ) {
52-
return new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options +
53-
'`.' );
53+
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
5454
}
5555
if ( hasOwnProp( options, 'database' ) ) {
5656
opts.database = options.database;
5757
if ( !isString( opts.database ) ) {
58-
return new TypeError( 'invalid option. `database` option must be a primitive string. Option: `' + opts.database + '`.' );
58+
return new TypeError( format( 'invalid option. `%s` option must be a string primitive. Option: `%s`.', 'database', opts.database ) );
5959
}
6060
}
6161
return null;

lib/node_modules/@stdlib/_tools/lint/namespace-aliases/lib/validate.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var isObject = require( '@stdlib/assert/is-plain-object' );
2424
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
2525
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
26+
var format = require( '@stdlib/string/format' );
2627

2728

2829
// MAIN //
@@ -49,13 +50,12 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
4950
*/
5051
function validate( opts, options ) {
5152
if ( !isObject( options ) ) {
52-
return new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options +
53-
'`.' );
53+
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
5454
}
5555
if ( hasOwnProp( options, 'dir' ) ) {
5656
opts.dir = options.dir;
5757
if ( !isString( opts.dir ) ) {
58-
return new TypeError( 'invalid option. `dir` option must be a primitive string. Option: `' + opts.dir + '`.' );
58+
return new TypeError( format( 'invalid option. `%s` option must be a string primitive. Option: `%s`.', 'dir', opts.dir ) );
5959
}
6060
}
6161
return null;

lib/node_modules/@stdlib/_tools/pkgs/browser-deps/lib/validate.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var isObject = require( '@stdlib/assert/is-plain-object' );
2424
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
2525
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2626
var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
27+
var format = require( '@stdlib/string/format' );
2728

2829

2930
// MAIN //
@@ -52,25 +53,24 @@ var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
5253
*/
5354
function validate( opts, options ) {
5455
if ( !isObject( options ) ) {
55-
return new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options +
56-
'`.' );
56+
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
5757
}
5858
if ( hasOwnProp( options, 'dir' ) ) {
5959
opts.dir = options.dir;
6060
if ( !isString( opts.dir ) ) {
61-
return new TypeError( 'invalid option. `dir` option must be a primitive string. Option: `' + opts.dir + '`.' );
61+
return new TypeError( format( 'invalid option. `%s` option must be a string primitive. Option: `%s`.', 'dir', opts.dir ) );
6262
}
6363
}
6464
if ( hasOwnProp( options, 'builtins' ) ) {
6565
opts.builtins = options.builtins;
6666
if ( !isBoolean( opts.builtins ) ) {
67-
return new TypeError( 'invalid option. `builtins` option must be a primitive boolean. Option: `' + opts.builtins + '`.' );
67+
return new TypeError( format( 'invalid option. `%s` option must be a boolean primitive. Option: `%s`.', 'builtins', opts.builtins ) );
6868
}
6969
}
7070
if ( hasOwnProp( options, 'dev' ) ) {
7171
opts.dev = options.dev;
7272
if ( !isBoolean( opts.dev ) ) {
73-
return new TypeError( 'invalid option. `dev` option must be a primitive boolean. Option: `' + opts.dev + '`.' );
73+
return new TypeError( format( 'invalid option. `%s` option must be a boolean primitive. Option: `%s`.', 'dev', opts.dev ) );
7474
}
7575
}
7676
return null;

lib/node_modules/@stdlib/_tools/pkgs/browser-entry-points/lib/validate.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var isObject = require( '@stdlib/assert/is-plain-object' );
2424
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
2525
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
26+
var format = require( '@stdlib/string/format' );
2627

2728

2829
// MAIN //
@@ -49,13 +50,12 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
4950
*/
5051
function validate( opts, options ) {
5152
if ( !isObject( options ) ) {
52-
return new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options +
53-
'`.' );
53+
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
5454
}
5555
if ( hasOwnProp( options, 'dir' ) ) {
5656
opts.dir = options.dir;
5757
if ( !isString( opts.dir ) ) {
58-
return new TypeError( 'invalid option. `dir` option must be a primitive string. Option: `' + opts.dir + '`.' );
58+
return new TypeError( format( 'invalid option. `%s` option must be a string primitive. Option: `%s`.', 'dir', opts.dir ) );
5959
}
6060
}
6161
return null;

lib/node_modules/@stdlib/_tools/pkgs/deps/lib/validate.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var isObject = require( '@stdlib/assert/is-plain-object' );
2424
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
2525
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2626
var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
27+
var format = require( '@stdlib/string/format' );
2728

2829

2930
// MAIN //
@@ -52,25 +53,24 @@ var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
5253
*/
5354
function validate( opts, options ) {
5455
if ( !isObject( options ) ) {
55-
return new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options +
56-
'`.' );
56+
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
5757
}
5858
if ( hasOwnProp( options, 'dir' ) ) {
5959
opts.dir = options.dir;
6060
if ( !isString( opts.dir ) ) {
61-
return new TypeError( 'invalid option. `dir` option must be a primitive string. Option: `' + opts.dir + '`.' );
61+
return new TypeError( format( 'invalid option. `%s` option must be a string primitive. Option: `%s`.', 'dir', opts.dir ) );
6262
}
6363
}
6464
if ( hasOwnProp( options, 'builtins' ) ) {
6565
opts.builtins = options.builtins;
6666
if ( !isBoolean( opts.builtins ) ) {
67-
return new TypeError( 'invalid option. `builtins` option must be a primitive boolean. Option: `' + opts.builtins + '`.' );
67+
return new TypeError( format( 'invalid option. `%s` option must be a boolean primitive. Option: `%s`.', 'builtins', opts.builtins ) );
6868
}
6969
}
7070
if ( hasOwnProp( options, 'dev' ) ) {
7171
opts.dev = options.dev;
7272
if ( !isBoolean( opts.dev ) ) {
73-
return new TypeError( 'invalid option. `dev` option must be a primitive boolean. Option: `' + opts.dev + '`.' );
73+
return new TypeError( format( 'invalid option. `%s` option must be a boolean primitive. Option: `%s`.', 'dev', opts.dev ) );
7474
}
7575
}
7676
return null;

0 commit comments

Comments
 (0)