Skip to content

Commit 2cb4cbc

Browse files
committed
Format error messages
1 parent 04164c1 commit 2cb4cbc

File tree

54 files changed

+149
-98
lines changed

Some content is hidden

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

54 files changed

+149
-98
lines changed

lib/node_modules/@stdlib/_tools/benchmarks/browser-build/lib/build.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var bundle = require( '@stdlib/_tools/benchmarks/bundle' );
2727
var html = require( '@stdlib/_tools/benchmarks/html' );
2828
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2929
var isFunction = require( '@stdlib/assert/is-function' );
30+
var format = require( '@stdlib/string/format' );
3031
var cwd = require( '@stdlib/process/cwd' );
3132
var copy = require( '@stdlib/utils/copy' );
3233
var defaults = require( './defaults.json' );
@@ -92,10 +93,10 @@ function build( root, output, options, clbk ) {
9293
var d;
9394

9495
if ( !isString( root ) ) {
95-
throw new TypeError( 'invalid argument. First argument must be a string. Value: `'+root+'`.' );
96+
throw new TypeError( format( 'invalid argument. First argument must be a string primitive. Value: `%1`.', root ) );
9697
}
9798
if ( !isString( output ) ) {
98-
throw new TypeError( 'invalid argument. Second argument must be a string. Value: `'+output+'`.' );
99+
throw new TypeError( format( 'invalid argument. Second argument must be a string primitive. Value: `%s`.', output ) );
99100
}
100101
opts = copy( defaults );
101102
if ( arguments.length < 4 ) {
@@ -108,7 +109,7 @@ function build( root, output, options, clbk ) {
108109
}
109110
}
110111
if ( !isFunction( cb ) ) {
111-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `'+cb+'`.' );
112+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', cb ) );
112113
}
113114
d = cwd();
114115
debug( 'Current working directory: %s', d );

lib/node_modules/@stdlib/_tools/benchmarks/bundle/lib/bundle.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var glob = require( 'glob' );
2626
var bundle = require( '@stdlib/_tools/browserify/file-list' );
2727
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2828
var isFunction = require( '@stdlib/assert/is-function' );
29+
var format = require( '@stdlib/string/format' );
2930
var cwd = require( '@stdlib/process/cwd' );
3031
var copy = require( '@stdlib/utils/copy' );
3132
var defaults = require( './defaults.json' );
@@ -78,7 +79,7 @@ function build( root, options, clbk ) {
7879
var d;
7980

8081
if ( !isString( root ) ) {
81-
throw new TypeError( 'invalid argument. First argument must be a string. Value: `'+root+'`.' );
82+
throw new TypeError( format( 'invalid argument. First argument must be a string primitive. Value: `%1`.', root ) );
8283
}
8384
opts = copy( defaults );
8485
if ( arguments.length < 3 ) {
@@ -91,7 +92,7 @@ function build( root, options, clbk ) {
9192
}
9293
}
9394
if ( !isFunction( cb ) ) {
94-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `'+cb+'`.' );
95+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', cb ) );
9596
}
9697
d = cwd();
9798
debug( 'Current working directory: %s', d );

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2727
var isFunction = require( '@stdlib/assert/is-function' );
2828
var readFileSync = require( '@stdlib/fs/read-file' ).sync;
2929
var writeFile = require( '@stdlib/fs/write-file' );
30+
var format = require( '@stdlib/string/format' );
3031
var cwd = require( '@stdlib/process/cwd' );
3132
var copy = require( '@stdlib/utils/copy' );
3233
var nextTick = require( '@stdlib/utils/next-tick' );
@@ -82,7 +83,7 @@ function build( bundle, options, clbk ) {
8283
var cb;
8384

8485
if ( !isString( bundle ) ) {
85-
throw new TypeError( 'invalid argument. First argument must be a string. Value: `'+bundle+'`.' );
86+
throw new TypeError( format( 'invalid argument. First argument must be a string primitive. Value: `%1`.', bundle ) );
8687
}
8788
opts = copy( defaults );
8889
if ( arguments.length < 3 ) {
@@ -95,7 +96,7 @@ function build( bundle, options, clbk ) {
9596
}
9697
}
9798
if ( !isFunction( cb ) ) {
98-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `'+cb+'`.' );
99+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', cb ) );
99100
}
100101
view = {
101102
'title': opts.title,

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var copy = require( '@stdlib/utils/copy' );
2727
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2828
var isFunction = require( '@stdlib/assert/is-function' );
2929
var tmpdir = require( '@stdlib/os/tmpdir' );
30+
var format = require( '@stdlib/string/format' );
3031
var cwd = require( '@stdlib/process/cwd' );
3132
var minstd = require( '@stdlib/random/base/minstd' );
3233
var readFile = require( '@stdlib/fs/read-file' );
@@ -76,7 +77,7 @@ function toReference( id, options, clbk ) {
7677
var cb;
7778

7879
if ( !isString( id ) ) {
79-
throw new TypeError( 'invalid argument. First argument must be a string primitive. Value: `' + id + '`.' );
80+
throw new TypeError( format( 'invalid argument. First argument must be a string primitive. Value: `%s`.', id ) );
8081
}
8182
opts = copy( defaults );
8283
if ( arguments.length < 3 ) {
@@ -89,7 +90,7 @@ function toReference( id, options, clbk ) {
8990
}
9091
}
9192
if ( !isFunction( cb ) ) {
92-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + cb + '`.' );
93+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', cb ) );
9394
}
9495
debug( 'Options: %s', JSON.stringify( opts ) );
9596

lib/node_modules/@stdlib/_tools/bundle/pkg-list/lib/main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives;
2727
var isFunction = require( '@stdlib/assert/is-function' );
2828
var isArray = require( '@stdlib/assert/is-array' );
2929
var browserifyString = require( '@stdlib/_tools/browserify/string' );
30+
var format = require( '@stdlib/string/format' );
3031
var browserifyPaths = require( './browserify_paths.js' );
3132
var validate = require( './validate.js' );
3233
var defaults = require( './defaults.json' );
@@ -95,7 +96,7 @@ function bundle( pkgs, options, clbk ) {
9596
var i;
9697

9798
if ( !isStringArray( pkgs ) ) {
98-
throw new TypeError( 'invalid argument. First argument must be an array of strings. Value: `'+pkgs+'`.' );
99+
throw new TypeError( format( 'invalid argument. First argument must be an array of strings. Value: `%s`.', pkgs ) );
99100
}
100101
opts = copy( defaults );
101102
if ( arguments.length > 2 ) {
@@ -108,7 +109,7 @@ function bundle( pkgs, options, clbk ) {
108109
cb = options;
109110
}
110111
if ( !isFunction( cb ) ) {
111-
throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+cb+'`.' );
112+
throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', cb ) );
112113
}
113114
debug( 'Options: %s', JSON.stringify( opts ) );
114115

lib/node_modules/@stdlib/_tools/docs/www/benchmark-bundles/lib/validate.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ 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;
2626
var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives;
27+
var format = require( '@stdlib/string/format' );
2728

2829

2930
// MAIN //
@@ -57,55 +58,54 @@ var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives;
5758
*/
5859
function validate( opts, options ) {
5960
if ( !isObject( options ) ) {
60-
return new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options +
61-
'`.' );
61+
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
6262
}
6363
if ( hasOwnProp( options, 'bundle' ) ) {
6464
opts.bundle = options.bundle;
6565
if ( !isString( opts.bundle ) ) {
66-
return new TypeError( 'invalid option. `bundle` option must be a string. Option: `'+opts.bundle+'`.' );
66+
return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'bundle', opts.bundle ) );
6767
}
6868
}
6969
if ( hasOwnProp( options, 'dir' ) ) {
7070
opts.dir = options.dir;
7171
if ( !isString( opts.dir ) ) {
72-
return new TypeError( 'invalid option. `dir` option must be a string. Option: `'+opts.dir+'`.' );
72+
return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'dir', opts.dir ) );
7373
}
7474
}
7575
if ( hasOwnProp( options, 'html' ) ) {
7676
opts.html = options.html;
7777
if ( !isString( opts.html ) ) {
78-
return new TypeError( 'invalid option. `html` option must be a string. Option: `'+opts.html+'`.' );
78+
return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'html', opts.html ) );
7979
}
8080
}
8181
if ( hasOwnProp( options, 'ignore' ) ) {
8282
opts.ignore = options.ignore;
8383
if ( !isStringArray( opts.ignore ) ) {
84-
return new TypeError( 'invalid option. `ignore` option must be an array of strings. Option: `'+opts.ignore+'`.' );
84+
return new TypeError( format( 'invalid option. `%s` option must be an array of strings. Option: `%s`.', 'ignore', opts.ignore ) );
8585
}
8686
}
8787
if ( hasOwnProp( options, 'mount' ) ) {
8888
opts.mount = options.mount;
8989
if ( !isString( opts.mount ) ) {
90-
return new TypeError( 'invalid option. `mount` option must be a string. Option: `'+opts.mount+'`.' );
90+
return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'mount', opts.mount ) );
9191
}
9292
}
9393
if ( hasOwnProp( options, 'packages_pattern' ) ) {
9494
opts.packages_pattern = options.packages_pattern;
9595
if ( !isString( opts.packages_pattern ) ) {
96-
return new TypeError( 'invalid option. `packages_pattern` option must be a string. Option: `'+opts.packages_pattern+'`.' );
96+
return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'packages_pattern', opts.packages_pattern ) );
9797
}
9898
}
9999
if ( hasOwnProp( options, 'files_pattern' ) ) {
100100
opts.files_pattern = options.files_pattern;
101101
if ( !isString( opts.files_pattern ) ) {
102-
return new TypeError( 'invalid option. `files_pattern` option must be a string. Option: `'+opts.files_pattern+'`.' );
102+
return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'files_pattern', opts.files_pattern ) );
103103
}
104104
}
105105
if ( hasOwnProp( options, 'title' ) ) {
106106
opts.title = options.title;
107107
if ( !isString( opts.title ) ) {
108-
return new TypeError( 'invalid option. `title` option must be a string. Option: `'+opts.title+'`.' );
108+
return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'title', opts.title ) );
109109
}
110110
}
111111
return null;

lib/node_modules/@stdlib/_tools/docs/www/test-bundles/lib/validate.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ 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;
2626
var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives;
27+
var format = require( '@stdlib/string/format' );
2728

2829

2930
// MAIN //
@@ -57,55 +58,54 @@ var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives;
5758
*/
5859
function validate( opts, options ) {
5960
if ( !isObject( options ) ) {
60-
return new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options +
61-
'`.' );
61+
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
6262
}
6363
if ( hasOwnProp( options, 'bundle' ) ) {
6464
opts.bundle = options.bundle;
6565
if ( !isString( opts.bundle ) ) {
66-
return new TypeError( 'invalid option. `bundle` option must be a string. Option: `'+opts.bundle+'`.' );
66+
return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'bundle', opts.bundle ) );
6767
}
6868
}
6969
if ( hasOwnProp( options, 'dir' ) ) {
7070
opts.dir = options.dir;
7171
if ( !isString( opts.dir ) ) {
72-
return new TypeError( 'invalid option. `dir` option must be a string. Option: `'+opts.dir+'`.' );
72+
return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'dir', opts.dir ) );
7373
}
7474
}
7575
if ( hasOwnProp( options, 'html' ) ) {
7676
opts.html = options.html;
7777
if ( !isString( opts.html ) ) {
78-
return new TypeError( 'invalid option. `html` option must be a string. Option: `'+opts.html+'`.' );
78+
return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'html', opts.html ) );
7979
}
8080
}
8181
if ( hasOwnProp( options, 'ignore' ) ) {
8282
opts.ignore = options.ignore;
8383
if ( !isStringArray( opts.ignore ) ) {
84-
return new TypeError( 'invalid option. `ignore` option must be an array of strings. Option: `'+opts.ignore+'`.' );
84+
return new TypeError( format( 'invalid option. `%s` option must be an array of strings. Option: `%s`.', 'ignore', opts.ignore ) );
8585
}
8686
}
8787
if ( hasOwnProp( options, 'mount' ) ) {
8888
opts.mount = options.mount;
8989
if ( !isString( opts.mount ) ) {
90-
return new TypeError( 'invalid option. `mount` option must be a string. Option: `'+opts.mount+'`.' );
90+
return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'mount', opts.mount ) );
9191
}
9292
}
9393
if ( hasOwnProp( options, 'packages_pattern' ) ) {
9494
opts.packages_pattern = options.packages_pattern;
9595
if ( !isString( opts.packages_pattern ) ) {
96-
return new TypeError( 'invalid option. `packages_pattern` option must be a string. Option: `'+opts.packages_pattern+'`.' );
96+
return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'packages_pattern', opts.packages_pattern ) );
9797
}
9898
}
9999
if ( hasOwnProp( options, 'files_pattern' ) ) {
100100
opts.files_pattern = options.files_pattern;
101101
if ( !isString( opts.files_pattern ) ) {
102-
return new TypeError( 'invalid option. `files_pattern` option must be a string. Option: `'+opts.files_pattern+'`.' );
102+
return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'files_pattern', opts.files_pattern ) );
103103
}
104104
}
105105
if ( hasOwnProp( options, 'title' ) ) {
106106
opts.title = options.title;
107107
if ( !isString( opts.title ) ) {
108-
return new TypeError( 'invalid option. `title` option must be a string. Option: `'+opts.title+'`.' );
108+
return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'title', opts.title ) );
109109
}
110110
}
111111
return null;

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

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

2323
var isFunction = require( '@stdlib/assert/is-function' );
2424
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
25+
var format = require( '@stdlib/string/format' );
2526
var copy = require( '@stdlib/utils/copy' );
2627
var validate = require( './validate.js' );
2728
var defaults = require( './defaults.json' );
@@ -85,10 +86,10 @@ function createIssue( slug, title, options, clbk ) {
8586
var opts;
8687
var err;
8788
if ( !isString( slug ) ) {
88-
throw new TypeError( 'invalid argument. Repository slug must be a string primitive. Value: `' + slug + '`.' );
89+
throw new TypeError( format( 'invalid argument. Repository slug must be a string primitive. Value: `%s`.', slug ) );
8990
}
9091
if ( !isString( title ) ) {
91-
throw new TypeError( 'invalid argument. Issue title must be a string primitive. Value: `' + title + '`.' );
92+
throw new TypeError( format( 'invalid argument. Issue title must be a string primitive. Value: `%s`.', title ) );
9293
}
9394
opts = copy( defaults );
9495
err = validate( opts, options );
@@ -103,7 +104,7 @@ function createIssue( slug, title, options, clbk ) {
103104
}
104105
}
105106
if ( !isFunction( clbk ) ) {
106-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + clbk + '`.' );
107+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );
107108
}
108109
query( slug, title, opts, done );
109110

lib/node_modules/@stdlib/_tools/github/starred/lib/factory.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 merge = require( '@stdlib/utils/merge' );
2526
var request = require( '@stdlib/_tools/github/get' ).factory;
2627
var validate = require( './validate.js' );
@@ -52,7 +53,7 @@ function factory( options, clbk ) {
5253
throw err;
5354
}
5455
if ( !isFunction( clbk ) ) {
55-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + clbk + '`.' );
56+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );
5657
}
5758
if (
5859
opts.token === void 0 &&

lib/node_modules/@stdlib/_tools/github/user-details/lib/factory.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 merge = require( '@stdlib/utils/merge' );
2526
var validate = require( './validate.js' );
2627
var defaults = require( './defaults.json' );
@@ -49,7 +50,7 @@ function factory( options, clbk ) {
4950
throw err;
5051
}
5152
if ( !isFunction( clbk ) ) {
52-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + clbk + '`.' );
53+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );
5354
}
5455
return userinfo;
5556

lib/node_modules/@stdlib/_tools/github/user-orgs/lib/factory.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 merge = require( '@stdlib/utils/merge' );
2526
var request = require( '@stdlib/_tools/github/get' ).factory;
2627
var validate = require( './validate.js' );
@@ -51,7 +52,7 @@ function factory( options, clbk ) {
5152
throw err;
5253
}
5354
if ( !isFunction( clbk ) ) {
54-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + clbk + '`.' );
55+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );
5556
}
5657
if (
5758
opts.token === void 0 &&

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var resolve = require( 'path' ).resolve;
2424
var createDebug = require( 'debug' );
2525
var readInstalled = require( 'read-installed' );
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 PINF = require( '@stdlib/constants/float64/pinf' );
@@ -80,7 +81,7 @@ function licenses() {
8081
}
8182
}
8283
if ( !isFunction( clbk ) ) {
83-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + clbk + '`.' );
84+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );
8485
}
8586
if ( opts.dir ) {
8687
opts.dir = resolve( cwd(), opts.dir );

lib/node_modules/@stdlib/_tools/lint/repl-txt/lib/async.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var resolve = require( 'path' ).resolve;
2424
var logger = require( 'debug' );
2525
var glob = require( 'glob' );
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 config = require( './config.json' );
@@ -85,7 +86,7 @@ function lint() {
8586
}
8687
}
8788
if ( !isFunction( clbk ) ) {
88-
throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + clbk + '`.' );
89+
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );
8990
}
9091
if ( opts.dir ) {
9192
dir = resolve( cwd(), opts.dir );

0 commit comments

Comments
 (0)