Skip to content

Commit 30e88de

Browse files
committed
Format error messages
1 parent eb0a47d commit 30e88de

File tree

58 files changed

+184
-129
lines changed

Some content is hidden

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

58 files changed

+184
-129
lines changed

lib/node_modules/@stdlib/array/to-sparse-iterator-right/lib/main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var isFunction = require( '@stdlib/assert/is-function' );
2525
var isCollection = require( '@stdlib/assert/is-collection' );
2626
var iteratorSymbol = require( '@stdlib/symbol/iterator' );
2727
var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
28+
var format = require( '@stdlib/string/format' );
2829

2930

3031
// MAIN //
@@ -64,12 +65,12 @@ function sparsearray2iteratorRight( src ) {
6465
var get;
6566
var i;
6667
if ( !isCollection( src ) ) {
67-
throw new TypeError( 'invalid argument. First argument must be an array-like object. Value: `' + src + '`.' );
68+
throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );
6869
}
6970
if ( arguments.length > 1 ) {
7071
fcn = arguments[ 1 ];
7172
if ( !isFunction( fcn ) ) {
72-
throw new TypeError( 'invalid argument. Second argument must be a function. Value: `' + fcn + '`.' );
73+
throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) );
7374
}
7475
thisArg = arguments[ 2 ];
7576
}

lib/node_modules/@stdlib/array/to-sparse-iterator/lib/main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var isFunction = require( '@stdlib/assert/is-function' );
2525
var isCollection = require( '@stdlib/assert/is-collection' );
2626
var iteratorSymbol = require( '@stdlib/symbol/iterator' );
2727
var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
28+
var format = require( '@stdlib/string/format' );
2829

2930

3031
// MAIN //
@@ -59,12 +60,12 @@ function sparsearray2iterator( src ) {
5960
var get;
6061
var i;
6162
if ( !isCollection( src ) ) {
62-
throw new TypeError( 'invalid argument. First argument must be an array-like object. Value: `' + src + '`.' );
63+
throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );
6364
}
6465
if ( arguments.length > 1 ) {
6566
fcn = arguments[ 1 ];
6667
if ( !isFunction( fcn ) ) {
67-
throw new TypeError( 'invalid argument. Second argument must be a function. Value: `' + fcn + '`.' );
68+
throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) );
6869
}
6970
thisArg = arguments[ 2 ];
7071
}

lib/node_modules/@stdlib/array/typed-real/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 ctors = require( '@stdlib/array/typed-ctors' );
2526

2627

@@ -122,7 +123,7 @@ function realarray() {
122123
}
123124
ctor = ctors( dtype );
124125
if ( ctor === null ) {
125-
throw new TypeError( 'invalid argument. Must provide a recognized data type. Value: `'+dtype+'`.' );
126+
throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );
126127
}
127128
if ( nargs <= 0 ) {
128129
return new ctor( 0 );

lib/node_modules/@stdlib/array/zeros-like/lib/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
// MODULES //
2222

23+
var format = require( '@stdlib/string/format' );
2324
var dtype = require( '@stdlib/array/dtype' );
2425
var zeros = require( '@stdlib/array/zeros' );
2526

@@ -46,7 +47,7 @@ var zeros = require( '@stdlib/array/zeros' );
4647
function zerosLike( x ) {
4748
var dt = dtype( x ); // delegate input argument validation to dtype resolution
4849
if ( dt === null ) {
49-
throw new TypeError( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `' + x + '`.' );
50+
throw new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) );
5051
}
5152
if ( arguments.length > 1 ) {
5253
dt = arguments[ 1 ];

lib/node_modules/@stdlib/assert/deep-has-own-property/lib/factory.js

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

2323
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2424
var isArray = require( '@stdlib/assert/is-array' );
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' );
@@ -53,7 +54,7 @@ function factory( path, options ) {
5354
var err;
5455
isStr = isString( path );
5556
if ( !isStr && !isArray( path ) ) {
56-
throw new TypeError( 'invalid argument. Key path must be a string primitive or a key array. Value: `' + path + '`.' );
57+
throw new TypeError( format( 'invalid argument. Key path must be a string primitive or a key array. Value: `%s`.', path ) );
5758
}
5859
opts = copy( defaults );
5960
if ( arguments.length > 1 ) {

lib/node_modules/@stdlib/assert/deep-has-own-property/lib/main.js

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

2323
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2424
var isArray = require( '@stdlib/assert/is-array' );
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' );
@@ -83,7 +84,7 @@ function deepHasOwnProp( value, path, options ) {
8384

8485
isStr = isString( path );
8586
if ( !isStr && !isArray( path ) ) {
86-
throw new TypeError( 'invalid argument. Key path must be a string primitive or a key array. Value: `' + path + '`.' );
87+
throw new TypeError( format( 'invalid argument. Key path must be a string primitive or a key array. Value: `%s`.', path ) );
8788
}
8889
opts = copy( defaults );
8990
if ( arguments.length > 2 ) {

lib/node_modules/@stdlib/assert/deep-has-property/lib/factory.js

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

2323
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2424
var isArray = require( '@stdlib/assert/is-array' );
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' );
@@ -53,7 +54,7 @@ function factory( path, options ) {
5354
var err;
5455
isStr = isString( path );
5556
if ( !isStr && !isArray( path ) ) {
56-
throw new TypeError( 'invalid argument. Key path must be a string primitive or a key array. Value: `' + path + '`.' );
57+
throw new TypeError( format( 'invalid argument. Key path must be a string primitive or a key array. Value: `%s`.', path ) );
5758
}
5859
opts = copy( defaults );
5960
if ( arguments.length > 1 ) {

lib/node_modules/@stdlib/error/to-json/lib/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var objectKeys = require( '@stdlib/utils/keys' );
2424
var copy = require( '@stdlib/utils/copy' );
2525
var isError = require( '@stdlib/assert/is-error' );
26+
var format = require( '@stdlib/string/format' );
2627
var typeName = require( './type.js' );
2728

2829

@@ -45,7 +46,7 @@ function toJSON( err ) {
4546
var out;
4647
var i;
4748
if ( !isError( err ) ) {
48-
throw new TypeError( 'invalid argument. Must provide an error object. Value: `' + err + '`.' );
49+
throw new TypeError( format( 'invalid argument. Must provide an error object. Value: `%s`.', err ) );
4950
}
5051
out = {};
5152

lib/node_modules/@stdlib/error/tools/id2pkg/lib/main.js

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

2323
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2424
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
25+
var format = require( '@stdlib/string/format' );
2526
var ID_TO_PKG = require( './../data/data.json' );
2627

2728

@@ -40,7 +41,7 @@ var ID_TO_PKG = require( './../data/data.json' );
4041
*/
4142
function id2pkg( id ) {
4243
if ( !isString( id ) ) {
43-
throw new TypeError( 'invalid argument. Must provide a string. Value: `' + id + '`.' );
44+
throw new TypeError( format( 'invalid argument. Must provide a string. Value: `%s`.', id ) );
4445
}
4546
if ( hasOwnProp( ID_TO_PKG, id ) ) {
4647
return ID_TO_PKG[ id ];

lib/node_modules/@stdlib/error/tools/pkg2id/lib/main.js

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

2323
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2424
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
25+
var format = require( '@stdlib/string/format' );
2526
var INTERNAL_TO_ID = require( './../data/internal.json' );
2627
var STANDALONE_TO_ID = require( './../data/standalone.json' );
2728

@@ -41,7 +42,7 @@ var STANDALONE_TO_ID = require( './../data/standalone.json' );
4142
*/
4243
function pkg2id( pkg ) {
4344
if ( !isString( pkg ) ) {
44-
throw new TypeError( 'invalid argument. Must provide a string. Value: `' + pkg + '`.' );
45+
throw new TypeError( format( 'invalid argument. Must provide a string. Value: `%s`.', pkg ) );
4546
}
4647
if ( hasOwnProp( INTERNAL_TO_ID, pkg ) ) {
4748
return INTERNAL_TO_ID[ pkg ];

0 commit comments

Comments
 (0)