Skip to content

Commit 6101e6c

Browse files
committed
Format error messages
1 parent 2188325 commit 6101e6c

File tree

68 files changed

+195
-124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+195
-124
lines changed

lib/node_modules/@stdlib/_tools/benchmarks/html/lib/validate.js

Lines changed: 4 additions & 4 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-plain-object' );
2525
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
26+
var format = require( '@stdlib/string/format' );
2627

2728

2829
// MAIN //
@@ -50,19 +51,18 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
5051
*/
5152
function validate( opts, options ) {
5253
if ( !isObject( options ) ) {
53-
return new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options +
54-
'`.' );
54+
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
5555
}
5656
if ( hasOwnProp( options, 'out' ) ) {
5757
opts.out = options.out;
5858
if ( !isString( opts.out ) ) {
59-
return new TypeError( 'invalid option. `out` option must be a string. Option: `'+opts.out+'`.' );
59+
return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'out', opts.out ) );
6060
}
6161
}
6262
if ( hasOwnProp( options, 'title' ) ) {
6363
opts.title = options.title;
6464
if ( !isString( opts.title ) ) {
65-
return new TypeError( 'invalid option. `title` option must be a string. Option: `'+opts.title+'`.' );
65+
return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'title', opts.title ) );
6666
}
6767
}
6868
return null;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var cwd = require( '@stdlib/process/cwd' );
3030
var minstd = require( '@stdlib/random/base/minstd' );
3131
var readFile = require( '@stdlib/fs/read-file' ).sync;
3232
var writeFile = require( '@stdlib/fs/write-file' ).sync;
33+
var format = require( '@stdlib/string/format' );
3334
var defaults = require( './defaults.js' );
3435
var validate = require( './validate.js' );
3536
var wrap = require( './wrap.js' );
@@ -70,7 +71,7 @@ function toReference( id, options ) {
7071
var err;
7172

7273
if ( !isString( id ) ) {
73-
throw new TypeError( 'invalid argument. First argument must be a string primitive. Value: `' + id + '`.' );
74+
throw new TypeError( format( 'invalid argument. First argument must be a string primitive. Value: `%s`.', id ) );
7475
}
7576
opts = copy( defaults );
7677
if ( arguments.length > 1 ) {

lib/node_modules/@stdlib/_tools/browserify/file-list/lib/main.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives;
2626
var isFunction = require( '@stdlib/assert/is-function' );
2727
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2828
var writeFile = require( '@stdlib/fs/write-file' );
29+
var format = require( '@stdlib/string/format' );
2930

3031

3132
// VARIABLES //
@@ -64,19 +65,19 @@ function bundle( files, dest, clbk ) {
6465
var b;
6566

6667
if ( !isStringArray( files ) ) {
67-
throw new TypeError( 'invalid argument. First argument must be an array of string primitives. Value: `'+files+'`.' );
68+
throw new TypeError( format( 'invalid argument. First argument must be an array of string primitives. Value: `%s`.', files ) );
6869
}
6970
if ( arguments.length < 3 ) {
7071
cb = dest;
7172
} else {
7273
if ( !isString( dest ) ) {
73-
throw new TypeError( 'invalid argument. Second argument must be a string primitive. Value: `'+dest+'`.' );
74+
throw new TypeError( format( 'invalid argument. Second argument must be a string primitive. Value: `%1`.', dest ) );
7475
}
7576
out = dest;
7677
cb = clbk;
7778
}
7879
if ( !isFunction( cb ) ) {
79-
throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+cb+'`.' );
80+
throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', cb ) );
8081
}
8182
opts = {
8283
'transform': [ 'envify' ],

lib/node_modules/@stdlib/streams/node/transform/lib/object_mode.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
// MODULES //
2222

2323
var isObject = require( '@stdlib/assert/is-plain-object' );
24+
var format = require( '@stdlib/string/format' );
2425
var copy = require( '@stdlib/utils/copy' );
2526
var Stream = require( './main.js' );
2627

@@ -74,7 +75,7 @@ function objectMode( options ) {
7475
var opts;
7576
if ( arguments.length ) {
7677
if ( !isObject( options ) ) {
77-
throw new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options + '`.' );
78+
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
7879
}
7980
opts = copy( options );
8081
} else {

lib/node_modules/@stdlib/string/acronym/lib/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var replace = require( '@stdlib/string/replace' );
2626
var uppercase = require( '@stdlib/string/uppercase' );
2727
var lowercase = require( '@stdlib/string/lowercase' );
2828
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
29+
var format = require( '@stdlib/string/format' );
2930
var validate = require( './validate.js' );
3031
var STOPWORDS = require( './stopwords.json' );
3132

@@ -74,7 +75,7 @@ function acronym( str, options ) {
7475
var i;
7576

7677
if ( !isString( str ) ) {
77-
throw new TypeError( 'invalid argument. First argument must be a string primitive. Value: `' + str + '`.' );
78+
throw new TypeError( format( 'invalid argument. First argument must be a string primitive. Value: `%s`.', str ) );
7879
}
7980
opts = {};
8081
if ( arguments.length > 1 ) {

lib/node_modules/@stdlib/string/camelcase/lib/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2424
var capitalize = require( '@stdlib/string/capitalize' );
2525
var lowercase = require( '@stdlib/string/lowercase' );
2626
var replace = require( '@stdlib/string/replace' );
27+
var format = require( '@stdlib/string/format' );
2728
var trim = require( '@stdlib/string/trim' );
2829

2930

@@ -79,7 +80,7 @@ function replacer( match, p1, offset ) {
7980
*/
8081
function camelcase( str ) {
8182
if ( !isString( str ) ) {
82-
throw new TypeError( 'invalid argument. First argument must be a string. Value: `' + str + '`.' );
83+
throw new TypeError( format( 'invalid argument. First argument must be a string primitive. Value: `%s`.', str ) );
8384
}
8485
str = replace( str, RE_SPECIAL, ' ' );
8586
str = replace( str, RE_WHITESPACE, ' ' );

lib/node_modules/@stdlib/string/capitalize/lib/capitalize.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
// MODULES //
2222

2323
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
24+
var format = require( '@stdlib/string/format' );
2425

2526

2627
// MAIN //
@@ -50,7 +51,7 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
5051
*/
5152
function capitalize( str ) {
5253
if ( !isString( str ) ) {
53-
throw new TypeError( 'invalid argument. First argument must be a string primitive. Value: `' + str + '`.' );
54+
throw new TypeError( format( 'invalid argument. First argument must be a string primitive. Value: `%s`.', str ) );
5455
}
5556
if ( str === '' ) {
5657
return '';

lib/node_modules/@stdlib/string/constantcase/lib/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2424
var uppercase = require( '@stdlib/string/uppercase' );
2525
var replace = require( '@stdlib/string/replace' );
26+
var format = require( '@stdlib/string/format' );
2627
var trim = require( '@stdlib/string/trim' );
2728

2829

@@ -60,7 +61,7 @@ var RE_CAMEL = /([a-z0-9])([A-Z])/g;
6061
*/
6162
function constantcase( str ) {
6263
if ( !isString( str ) ) {
63-
throw new TypeError( 'invalid argument. Must provide a string. Value: `' + str + '`.' );
64+
throw new TypeError( format( 'invalid argument. Must provide a string. Value: `%s`.', str ) );
6465
}
6566
str = replace( str, RE_SPECIAL, ' ' );
6667
str = replace( str, RE_CAMEL, '$1 $2' );

lib/node_modules/@stdlib/string/ends-with/lib/ends_with.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive;
2424
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
25+
var format = require( '@stdlib/string/format' );
2526

2627

2728
// MAIN //
@@ -61,14 +62,14 @@ function endsWith( str, search, len ) {
6162
var idx;
6263
var i;
6364
if ( !isString( str ) ) {
64-
throw new TypeError( 'invalid argument. First argument must be a string primitive. Value: `' + str + '`.' );
65+
throw new TypeError( format( 'invalid argument. First argument must be a string primitive. Value: `%s`.', str ) );
6566
}
6667
if ( !isString( search ) ) {
67-
throw new TypeError( 'invalid argument. Second argument must be a string primitive. Value: `' + search + '`.' );
68+
throw new TypeError( format( 'invalid argument. Second argument must be a string primitive. Value: `%s`.', search ) );
6869
}
6970
if ( arguments.length > 2 ) {
7071
if ( !isInteger( len ) ) {
71-
throw new TypeError( 'invalid argument. Third argument must be an integer. Value: `' + len + '`.' );
72+
throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', len ) );
7273
}
7374
if ( len === 0 ) {
7475
return ( search.length === 0 );

lib/node_modules/@stdlib/string/lowercase/lib/lowercase.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
// MODULES //
2222

2323
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
24+
var format = require( '@stdlib/string/format' );
2425

2526

2627
// MAIN //
@@ -38,7 +39,7 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
3839
*/
3940
function lowercase( str ) {
4041
if ( !isString( str ) ) {
41-
throw new TypeError( 'invalid argument. Must provide a primitive string. Value: `'+str+'`.' );
42+
throw new TypeError( format( 'invalid argument. Must provide a primitive string. Value: `%s`.', str ) );
4243
}
4344
return str.toLowerCase();
4445
}

0 commit comments

Comments
 (0)