Skip to content

Commit 1c7517b

Browse files
committed
Format error messages
1 parent 249d2b2 commit 1c7517b

File tree

55 files changed

+202
-149
lines changed

Some content is hidden

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

55 files changed

+202
-149
lines changed

lib/node_modules/@stdlib/_tools/modules/pkg-deps/lib/async.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var isFunction = require( '@stdlib/assert/is-function' );
2828
var copy = require( '@stdlib/utils/copy' );
2929
var cwd = require( '@stdlib/process/cwd' );
3030
var dirname = require( '@stdlib/utils/dirname' );
31+
var format = require( '@stdlib/string/format' );
3132
var defaults = require( './defaults.json' );
3233
var validate = require( './validate.js' );
3334
var walkFile = require( './walk_file.js' );
@@ -89,7 +90,7 @@ function pkgDeps( files, options, clbk ) {
8990
!isStr &&
9091
!isStringArray( files )
9192
) {
92-
throw new TypeError( 'invalid argument. First argument must be either a string or string array. Value: `' + files + '`.' );
93+
throw new TypeError( format( 'invalid argument. First argument must be either a string or string array. Value: `%s`.', files ) );
9394
}
9495
if ( isStr ) {
9596
list = [ files ];
@@ -107,7 +108,7 @@ function pkgDeps( files, options, clbk ) {
107108
}
108109
}
109110
if ( !isFunction( cb ) ) {
110-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + cb + '`.' );
111+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', cb ) );
111112
}
112113
debug( 'Options: %s', JSON.stringify( opts ) );
113114
aliases = opts.aliases;

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var path = require( 'path' );
2424
var logger = require( 'debug' );
2525
var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives;
2626
var isFunction = require( '@stdlib/assert/is-function' );
27+
var format = require( '@stdlib/string/format' );
2728
var cwd = require( '@stdlib/process/cwd' );
2829
var copy = require( '@stdlib/utils/copy' );
2930
var defaults = require( './defaults.json' );
@@ -69,7 +70,7 @@ function entryPoints( pkgs, options, clbk ) {
6970
var dir;
7071
var cb;
7172
if ( !isStringArray( pkgs ) ) {
72-
throw new TypeError( 'invalid argument. First argument must be a string array. Value: `' + pkgs + '`.' );
73+
throw new TypeError( format( 'invalid argument. First argument must be a string array. Value: `%s`.', pkgs ) );
7374
}
7475
opts = copy( defaults );
7576
if ( arguments.length < 3 ) {
@@ -82,7 +83,7 @@ function entryPoints( pkgs, options, clbk ) {
8283
}
8384
}
8485
if ( !isFunction( cb ) ) {
85-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + cb + '`.' );
86+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', cb ) );
8687
}
8788
debug( 'Options: %s', JSON.stringify( opts ) );
8889
if ( opts.dir ) {

lib/node_modules/@stdlib/_tools/search/pkg-index/lib/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var path = require( 'path' );
2424
var logger = require( 'debug' );
2525
var readFileList = require( '@stdlib/fs/read-file-list' );
2626
var isFunction = require( '@stdlib/assert/is-function' );
27+
var format = require( '@stdlib/string/format' );
2728
var copy = require( '@stdlib/utils/copy' );
2829
var cwd = require( '@stdlib/process/cwd' );
2930
var findReadmes = require( '@stdlib/_tools/pkgs/readmes' );
@@ -88,7 +89,7 @@ function pkgIndex() {
8889
}
8990
}
9091
if ( !isFunction( clbk ) ) {
91-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + clbk + '`.' );
92+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );
9293
}
9394
if ( opts.dir ) {
9495
opts.dir = path.resolve( cwd(), opts.dir );

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var resolve = require( 'path' ).resolve;
2424
var logger = require( 'debug' );
2525
var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives;
2626
var isFunction = require( '@stdlib/assert/is-function' );
27+
var format = require( '@stdlib/string/format' );
2728
var lloc = require( '@stdlib/_tools/static-analysis/js/lloc' );
2829
var incrlloc = require( '@stdlib/_tools/static-analysis/js/incr/lloc' );
2930
var readFile = require( '@stdlib/fs/read-file' );
@@ -77,7 +78,7 @@ function analyze( files, options, clbk ) {
7778
var dir;
7879
var cb;
7980
if ( !isStringArray( files ) ) {
80-
throw new TypeError( 'invalid argument. First argument must be a list of file paths. Value: `' + files + '`.' );
81+
throw new TypeError( format( 'invalid argument. First argument must be a list of file paths. Value: `%s`.', files ) );
8182
}
8283
nfiles = files.length;
8384
debug( 'Files: %s', files.join( ', ' ) );
@@ -97,7 +98,7 @@ function analyze( files, options, clbk ) {
9798
cb = options;
9899
}
99100
if ( !isFunction( cb ) ) {
100-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + cb + '`.' );
101+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', cb ) );
101102
}
102103
debug( 'Options: %s', JSON.stringify( opts ) );
103104

lib/node_modules/@stdlib/_tools/static-analysis/js/program-summary/lib/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var parse = require( 'acorn' ).parse;
2424
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2525
var isBuffer = require( '@stdlib/assert/is-buffer' );
26+
var format = require( '@stdlib/string/format' );
2627
var copy = require( '@stdlib/utils/copy' );
2728
var RE_EOL = require( '@stdlib/regexp/eol' ).REGEXP;
2829
var DEFAULTS = require( './defaults.json' );
@@ -60,7 +61,7 @@ function summary( input ) {
6061
var ast;
6162

6263
if ( !isString( input ) && !isBuffer( input ) ) {
63-
throw new TypeError( 'invalid argument. Must provide either a string or a Buffer. Value: `' + input + '`.' );
64+
throw new TypeError( format( 'invalid argument. Must provide either a string or a Buffer. Value: `%s`.', input ) );
6465
}
6566
// Ensure that provided input is a `string`:
6667
input = input.toString();

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var isFunction = require( '@stdlib/assert/is-function' );
2727
var sloc = require( '@stdlib/_tools/static-analysis/js/sloc' );
2828
var incrsloc = require( '@stdlib/_tools/static-analysis/js/incr/sloc' );
2929
var readFile = require( '@stdlib/fs/read-file' );
30+
var format = require( '@stdlib/string/format' );
3031
var cwd = require( '@stdlib/process/cwd' );
3132
var defaults = require( './defaults.json' );
3233
var validate = require( './validate.js' );
@@ -77,7 +78,7 @@ function analyze( files, options, clbk ) {
7778
var dir;
7879
var cb;
7980
if ( !isStringArray( files ) ) {
80-
throw new TypeError( 'invalid argument. First argument must be a list of file paths. Value: `' + files + '`.' );
81+
throw new TypeError( format( 'invalid argument. First argument must be a list of file paths. Value: `%s`.', files ) );
8182
}
8283
nfiles = files.length;
8384
debug( 'Files: %s', files.join( ', ' ) );
@@ -97,7 +98,7 @@ function analyze( files, options, clbk ) {
9798
cb = options;
9899
}
99100
if ( !isFunction( cb ) ) {
100-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + cb + '`.' );
101+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', cb ) );
101102
}
102103
debug( 'Options: %s', JSON.stringify( opts ) );
103104

lib/node_modules/@stdlib/_tools/static-analysis/js/sloc-glob/lib/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var logger = require( 'debug' );
2525
var glob = require( 'glob' );
2626
var copy = require( '@stdlib/utils/copy' );
2727
var isFunction = require( '@stdlib/assert/is-function' );
28+
var format = require( '@stdlib/string/format' );
2829
var sloc = require( '@stdlib/_tools/static-analysis/js/sloc-file-list' );
2930
var cwd = require( '@stdlib/process/cwd' );
3031
var defaults = require( './defaults.json' );
@@ -87,7 +88,7 @@ function analyze( options, clbk ) {
8788
cb = clbk;
8889
}
8990
if ( !isFunction( cb ) ) {
90-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + cb + '`.' );
91+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', cb ) );
9192
}
9293
debug( 'Options: %s', JSON.stringify( opts ) );
9394

lib/node_modules/@stdlib/_tools/static-analysis/js/summarize-file-list/lib/main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var isFunction = require( '@stdlib/assert/is-function' );
2727
var summary = require( '@stdlib/_tools/static-analysis/js/program-summary' );
2828
var incrsummary = require( '@stdlib/_tools/static-analysis/js/incr/program-summary' );
2929
var readFile = require( '@stdlib/fs/read-file' );
30+
var format = require( '@stdlib/string/format' );
3031
var cwd = require( '@stdlib/process/cwd' );
3132
var defaults = require( './defaults.json' );
3233
var validate = require( './validate.js' );
@@ -77,7 +78,7 @@ function analyze( files, options, clbk ) {
7778
var dir;
7879
var cb;
7980
if ( !isStringArray( files ) ) {
80-
throw new TypeError( 'invalid argument. First argument must be a list of file paths. Value: `' + files + '`.' );
81+
throw new TypeError( format( 'invalid argument. First argument must be a list of file paths. Value: `%s`.', files ) );
8182
}
8283
nfiles = files.length;
8384
debug( 'Files: %s', files.join( ', ' ) );
@@ -97,7 +98,7 @@ function analyze( files, options, clbk ) {
9798
cb = options;
9899
}
99100
if ( !isFunction( cb ) ) {
100-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + cb + '`.' );
101+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', cb ) );
101102
}
102103
debug( 'Options: %s', JSON.stringify( opts ) );
103104

lib/node_modules/@stdlib/_tools/static-analysis/js/summarize-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 summary = require( '@stdlib/_tools/static-analysis/js/program-summary' );
2727
var incrsummary = require( '@stdlib/_tools/static-analysis/js/incr/program-summary' );
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/summarize-glob/lib/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var glob = require( 'glob' );
2626
var copy = require( '@stdlib/utils/copy' );
2727
var isFunction = require( '@stdlib/assert/is-function' );
2828
var summarize = require( '@stdlib/_tools/static-analysis/js/summarize-file-list' );
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' );
@@ -86,7 +87,7 @@ function analyze( options, clbk ) {
8687
cb = clbk;
8788
}
8889
if ( !isFunction( cb ) ) {
89-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + cb + '`.' );
90+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', cb ) );
9091
}
9192
debug( 'Options: %s', JSON.stringify( opts ) );
9293

0 commit comments

Comments
 (0)