Skip to content

Commit ff308e9

Browse files
committed
Format error messages
1 parent 19689fd commit ff308e9

File tree

57 files changed

+176
-114
lines changed

Some content is hidden

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

57 files changed

+176
-114
lines changed

lib/node_modules/@stdlib/_tools/browserify/string/lib/main.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var tmpdir = require( '@stdlib/os/tmpdir' );
3030
var writeFile = require( '@stdlib/fs/write-file' );
3131
var rmfile = require( '@stdlib/fs/unlink' );
3232
var minstd = require( '@stdlib/random/base/minstd' );
33+
var format = require( '@stdlib/string/format' );
3334
var cwd = require( '@stdlib/process/cwd' );
3435
var IS_WINDOWS = require( '@stdlib/assert/is-windows' );
3536
var ENV = require( '@stdlib/process/env' );
@@ -86,15 +87,15 @@ function bundle( str, dest, options, clbk ) {
8687
var i;
8788

8889
if ( !isString( str ) ) {
89-
throw new TypeError( 'invalid argument. First argument must be a string primitive. Value: `'+str+'`.' );
90+
throw new TypeError( format( 'invalid argument. First argument must be a string primitive. Value: `%1`.', str ) );
9091
}
9192
nargs = arguments.length;
9293
opts = {};
9394
if ( nargs === 2 ) {
9495
cb = dest;
9596
} else if ( nargs >= 4 ) {
9697
if ( !isString( dest ) ) {
97-
throw new TypeError( 'invalid argument. Second argument must be a string primitive. Value: `'+dest+'`.' );
98+
throw new TypeError( format( 'invalid argument. Second argument must be a string primitive. Value: `%1`.', dest ) );
9899
}
99100
err = validate( opts, options );
100101
if ( err ) {
@@ -112,7 +113,7 @@ function bundle( str, dest, options, clbk ) {
112113
cb = options;
113114
}
114115
if ( !isFunction( cb ) ) {
115-
throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+cb+'`.' );
116+
throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', cb ) );
116117
}
117118
if ( opts.basedir === void 0 ) {
118119
opts.basedir = cwd();

lib/node_modules/@stdlib/_tools/github/create-token/lib/main.js

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

2323
var isFunction = require( '@stdlib/assert/is-function' );
24+
var format = require( '@stdlib/string/format' );
2425
var copy = require( '@stdlib/utils/copy' );
2526
var validate = require( './validate.js' );
2627
var defaults = require( './defaults.json' );
@@ -56,7 +57,7 @@ function create( options, clbk ) {
5657
throw err;
5758
}
5859
if ( !isFunction( clbk ) ) {
59-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + clbk + '`.' );
60+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );
6061
}
6162
query( opts, done );
6263
/**

lib/node_modules/@stdlib/_tools/lint/license-header/lib/main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2424
var isBuffer = require( '@stdlib/assert/is-buffer' );
2525
var isRegExp = require( '@stdlib/assert/is-regexp' );
26+
var format = require( '@stdlib/string/format' );
2627
var RE_EOL = require( '@stdlib/regexp/eol' ).REGEXP;
2728
var reFromString = require( '@stdlib/utils/regexp-from-string' );
2829
var replace = require( '@stdlib/string/replace' );
@@ -71,11 +72,11 @@ function lint( blob, header ) {
7172
var isStr;
7273
var tmp;
7374
if ( !isString( blob ) && !isBuffer( blob ) ) {
74-
throw new TypeError( 'invalid argument. First argument must be either a string or Buffer. Value: `' + blob + '`.' );
75+
throw new TypeError( format( 'invalid argument. First argument must be either a string or Buffer. Value: `%s`.', blob ) );
7576
}
7677
isStr = isString( header );
7778
if ( !isStr && !isRegExp( header ) ) {
78-
throw new TypeError( 'invalid argument. Second argument must be either a string or regular expression. Value: `' + header + '`.' );
79+
throw new TypeError( format( 'invalid argument. Second argument must be either a string or regular expression. Value: `%s`.', header ) );
7980
}
8081
blob = blob.toString();
8182
if ( isStr ) {

lib/node_modules/@stdlib/_tools/pkgs/clis/lib/async.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var resolve = require( 'path' ).resolve;
2424
var glob = require( 'glob' );
2525
var isFunction = require( '@stdlib/assert/is-function' );
26+
var format = require( '@stdlib/string/format' );
2627
var copy = require( '@stdlib/utils/copy' );
2728
var cwd = require( '@stdlib/process/cwd' );
2829
var config = require( './config.json' );
@@ -75,7 +76,7 @@ function findCLIs() {
7576
}
7677
}
7778
if ( !isFunction( clbk ) ) {
78-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + clbk + '`.' );
79+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );
7980
}
8081
if ( opts.dir ) {
8182
dir = resolve( cwd(), opts.dir );

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var path = require( 'path' );
2424
var logger = require( 'debug' );
2525
var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives;
26+
var format = require( '@stdlib/string/format' );
2627
var copy = require( '@stdlib/utils/copy' );
2728
var cwd = require( '@stdlib/process/cwd' );
2829
var entryPoints = require( '@stdlib/_tools/pkgs/entry-points' ).sync;
@@ -64,7 +65,7 @@ function pkgDeps( pkgs, options ) {
6465
var opts;
6566
var err;
6667
if ( !isStringArray( pkgs ) ) {
67-
throw new TypeError( 'invalid argument. First argument must be a string array. Value: `' + pkgs + '`.' );
68+
throw new TypeError( format( 'invalid argument. First argument must be a string array. Value: `%s`.', pkgs ) );
6869
}
6970
opts = copy( defaults );
7071
if ( arguments.length > 1 ) {

lib/node_modules/@stdlib/_tools/pkgs/includes/lib/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var resolve = require( 'path' ).resolve;
2424
var glob = require( 'glob' );
2525
var isFunction = require( '@stdlib/assert/is-function' );
26+
var format = require( '@stdlib/string/format' );
2627
var copy = require( '@stdlib/utils/copy' );
2728
var cwd = require( '@stdlib/process/cwd' );
2829
var config = require( './config.json' );
@@ -75,7 +76,7 @@ function findIncludes() {
7576
}
7677
}
7778
if ( !isFunction( clbk ) ) {
78-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + clbk + '`.' );
79+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );
7980
}
8081
if ( opts.dir ) {
8182
dir = resolve( cwd(), opts.dir );

lib/node_modules/@stdlib/_tools/static-analysis/js/lloc-file-list/lib/sync.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives;
2626
var lloc = require( '@stdlib/_tools/static-analysis/js/lloc' );
2727
var incrlloc = require( '@stdlib/_tools/static-analysis/js/incr/lloc' );
2828
var readFileSync = require( '@stdlib/fs/read-file' ).sync;
29+
var format = require( '@stdlib/string/format' );
2930
var cwd = require( '@stdlib/process/cwd' );
3031
var defaults = require( './defaults.json' );
3132
var validate = require( './validate.js' );
@@ -71,7 +72,7 @@ function analyze( files, options ) {
7172
var dir;
7273
var i;
7374
if ( !isStringArray( files ) ) {
74-
throw new TypeError( 'invalid argument. First argument must be a list of file paths. Value: `' + files + '`.' );
75+
throw new TypeError( format( 'invalid argument. First argument must be a list of file paths. Value: `%s`.', files ) );
7576
}
7677
nfiles = files.length;
7778
debug( 'Files: %s', files.join( ', ' ) );

lib/node_modules/@stdlib/_tools/static-analysis/js/sloc-file-list/lib/sync.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives;
2626
var sloc = require( '@stdlib/_tools/static-analysis/js/sloc' );
2727
var incrsloc = require( '@stdlib/_tools/static-analysis/js/incr/sloc' );
2828
var readFileSync = require( '@stdlib/fs/read-file' ).sync;
29+
var format = require( '@stdlib/string/format' );
2930
var cwd = require( '@stdlib/process/cwd' );
3031
var defaults = require( './defaults.json' );
3132
var validate = require( './validate.js' );
@@ -71,7 +72,7 @@ function analyze( files, options ) {
7172
var dir;
7273
var i;
7374
if ( !isStringArray( files ) ) {
74-
throw new TypeError( 'invalid argument. First argument must be a list of file paths. Value: `' + files + '`.' );
75+
throw new TypeError( format( 'invalid argument. First argument must be a list of file paths. Value: `%s`.', files ) );
7576
}
7677
nfiles = files.length;
7778
debug( 'Files: %s', files.join( ', ' ) );

lib/node_modules/@stdlib/_tools/tests/bundle/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, 'pattern' ) ) {
6363
opts.pattern = options.pattern;
6464
if ( !isString( opts.pattern ) ) {
65-
return new TypeError( 'invalid option. `pattern` option must be a string. Option: `'+opts.pattern+'`.' );
65+
return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'pattern', opts.pattern ) );
6666
}
6767
}
6868
return null;

lib/node_modules/@stdlib/repl/typed-signature/lib/main.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
var ALIAS_TO_TYPED_SIGNATURE = require( './../data/data.json' );
2526

2627

@@ -41,7 +42,7 @@ function typedSignature( alias ) {
4142
var out;
4243
var i;
4344
if ( !isString( alias ) ) {
44-
throw new TypeError( 'invalid argument. Must provide a string. Value: `' + alias + '`.' );
45+
throw new TypeError( format( 'invalid argument. Must provide a string. Value: `%s`.', alias ) );
4546
}
4647
out = [];
4748
for ( i = 0; i < ALIAS_TO_TYPED_SIGNATURE.length; i++ ) {

0 commit comments

Comments
 (0)