Skip to content

Commit 19689fd

Browse files
committed
Format error messages
1 parent 98a442e commit 19689fd

63 files changed

Lines changed: 193 additions & 130 deletions

File tree

Some content is hidden

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

lib/node_modules/@stdlib/stats/incr/cv/lib/main.js

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

2323
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
2424
var isnan = require( '@stdlib/math/base/assert/is-nan' );
25+
var format = require( '@stdlib/string/format' );
2526
var sqrt = require( '@stdlib/math/base/special/sqrt' );
2627

2728

@@ -98,7 +99,7 @@ function incrcv( mean ) {
9899
N = 0;
99100
if ( arguments.length ) {
100101
if ( !isNumber( mean ) ) {
101-
throw new TypeError( 'invalid argument. Must provide a number primitive. Value: `' + mean + '`.' );
102+
throw new TypeError( format( 'invalid argument. Must provide a number primitive. Value: `%s`.', mean ) );
102103
}
103104
mu = mean;
104105
return accumulator2;

lib/node_modules/@stdlib/stats/incr/mapcorr/lib/main.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive;
2424
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
2525
var incrmpcorr = require( '@stdlib/stats/incr/mpcorr' );
26+
var format = require( '@stdlib/string/format' );
2627
var abs = require( '@stdlib/math/base/special/abs' );
2728

2829

@@ -66,14 +67,14 @@ var abs = require( '@stdlib/math/base/special/abs' );
6667
function incrmapcorr( W, meanx, meany ) {
6768
var acc;
6869
if ( !isPositiveInteger( W ) ) {
69-
throw new TypeError( 'invalid argument. First argument must be a positive integer. Value: `' + W + '`.' );
70+
throw new TypeError( format( 'invalid argument. First argument must be a positive integer. Value: `%s`.', W ) );
7071
}
7172
if ( arguments.length > 1 ) {
7273
if ( !isNumber( meanx ) ) {
73-
throw new TypeError( 'invalid argument. Second argument must be a number primitive. Value: `' + meanx + '`.' );
74+
throw new TypeError( format( 'invalid argument. Second argument must be a number primitive. Value: `%s`.', meanx ) );
7475
}
7576
if ( !isNumber( meany ) ) {
76-
throw new TypeError( 'invalid argument. Third argument must be a number primitive. Value: `' + meany + '`.' );
77+
throw new TypeError( format( 'invalid argument. Third argument must be a number primitive. Value: `%s`.', meany ) );
7778
}
7879
acc = incrmpcorr( W, meanx, meany );
7980
} else {

lib/node_modules/@stdlib/stats/incr/mcovariance/lib/main.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimit
2424
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var Float64Array = require( '@stdlib/array/float64' );
27+
var format = require( '@stdlib/string/format' );
2728

2829

2930
// MAIN //
@@ -212,7 +213,7 @@ function incrmcovariance( W, meanx, meany ) {
212213
var n;
213214
var i;
214215
if ( !isPositiveInteger( W ) ) {
215-
throw new TypeError( 'invalid argument. First argument must be a positive integer. Value: `' + W + '`.' );
216+
throw new TypeError( format( 'invalid argument. First argument must be a positive integer. Value: `%s`.', W ) );
216217
}
217218
buf = new Float64Array( 2*W ); // strided array
218219
n = W - 1;
@@ -221,10 +222,10 @@ function incrmcovariance( W, meanx, meany ) {
221222
N = 0;
222223
if ( arguments.length > 1 ) {
223224
if ( !isNumber( meanx ) ) {
224-
throw new TypeError( 'invalid argument. Second argument must be a number primitive. Value: `' + meanx + '`.' );
225+
throw new TypeError( format( 'invalid argument. Second argument must be a number primitive. Value: `%s`.', meanx ) );
225226
}
226227
if ( !isNumber( meany ) ) {
227-
throw new TypeError( 'invalid argument. Third argument must be a number primitive. Value: `' + meany + '`.' );
228+
throw new TypeError( format( 'invalid argument. Third argument must be a number primitive. Value: `%s`.', meany ) );
228229
}
229230
mx = meanx;
230231
my = meany;

lib/node_modules/@stdlib/stats/incr/meanstdev/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 isArrayLike = require( '@stdlib/assert/is-array-like-object' );
24+
var format = require( '@stdlib/string/format' );
2425
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2526
var sqrt = require( '@stdlib/math/base/special/sqrt' );
2627

@@ -106,7 +107,7 @@ function incrmeanstdev( out ) {
106107
meanstdev = [ 0.0, 0.0 ];
107108
} else {
108109
if ( !isArrayLike( out ) ) {
109-
throw new TypeError( 'invalid argument. Output argument must be an array-like object. Value: `' + out + '`.' );
110+
throw new TypeError( format( 'invalid argument. Output argument must be an array-like object. Value: `%s`.', out ) );
110111
}
111112
meanstdev = out;
112113
}

lib/node_modules/@stdlib/stats/incr/meanvar/lib/main.js

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

2323
var isArrayLike = require( '@stdlib/assert/is-array-like-object' );
2424
var isnan = require( '@stdlib/math/base/assert/is-nan' );
25+
var format = require( '@stdlib/string/format' );
2526

2627

2728
// MAIN //
@@ -104,7 +105,7 @@ function incrmeanvar( out ) {
104105
meanvar = [ 0.0, 0.0 ];
105106
} else {
106107
if ( !isArrayLike( out ) ) {
107-
throw new TypeError( 'invalid argument. Output argument must be an array-like object. Value: `' + out + '`.' );
108+
throw new TypeError( format( 'invalid argument. Output argument must be an array-like object. Value: `%s`.', out ) );
108109
}
109110
meanvar = out;
110111
}

lib/node_modules/@stdlib/strided/base/unary-addon-dispatch/lib/unary.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' );
2525
var resolve = require( '@stdlib/strided/base/dtype-resolve-enum' );
2626
var reinterpretComplex64 = require( '@stdlib/strided/base/reinterpret-complex64' );
2727
var reinterpretComplex128 = require( '@stdlib/strided/base/reinterpret-complex128' );
28+
var format = require( '@stdlib/string/format' );
2829

2930

3031
// VARIABLES //
@@ -113,10 +114,10 @@ var COMPLEX128 = resolve( 'complex128' );
113114
*/
114115
function dispatch( addon, fallback ) {
115116
if ( !isFunction( addon ) ) {
116-
throw new TypeError( 'invalid argument. First argument must be a function. Value: `' + addon + '`.' );
117+
throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', addon ) );
117118
}
118119
if ( !isFunction( fallback ) ) {
119-
throw new TypeError( 'invalid argument. Second argument must be a function. Value: `' + fallback + '`.' );
120+
throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fallback ) );
120121
}
121122
return dispatcher;
122123

lib/node_modules/@stdlib/string/left-trim/lib/left_trim.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 replace = require( '@stdlib/string/replace' );
25+
var format = require( '@stdlib/string/format' );
2526

2627

2728
// VARIABLES //
@@ -53,7 +54,7 @@ var RE = /^[\u0020\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3
5354
*/
5455
function ltrim( str ) {
5556
if ( !isString( str ) ) {
56-
throw new TypeError( 'invalid argument. Must provide a string primitive. Value: `' + str + '`.' );
57+
throw new TypeError( format( 'invalid argument. Must provide a string primitive. Value: `%s`.', str ) );
5758
}
5859
return replace( str, RE, '' );
5960
}

lib/node_modules/@stdlib/utils/any-by-right/lib/any_by_right.js

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

2323
var isCollection = require( '@stdlib/assert/is-collection' );
2424
var isFunction = require( '@stdlib/assert/is-function' );
25+
var format = require( '@stdlib/string/format' );
2526

2627

2728
// MAIN //
@@ -51,10 +52,10 @@ function anyByRight( collection, predicate, thisArg ) {
5152
var len;
5253
var i;
5354
if ( !isCollection( collection ) ) {
54-
throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' );
55+
throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) );
5556
}
5657
if ( !isFunction( predicate ) ) {
57-
throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+predicate+'`.' );
58+
throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) );
5859
}
5960
len = collection.length;
6061
for ( i = len-1; i >= 0; i-- ) {

lib/node_modules/@stdlib/utils/async/any-by-right/lib/factory.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 isCollection = require( '@stdlib/assert/is-collection' );
25+
var format = require( '@stdlib/string/format' );
2526
var PINF = require( '@stdlib/constants/float64/pinf' );
2627
var validate = require( './validate.js' );
2728
var limit = require( './limit.js' );
@@ -109,7 +110,7 @@ function factory( options, predicate ) {
109110
f = options;
110111
}
111112
if ( !isFunction( f ) ) {
112-
throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' );
113+
throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) );
113114
}
114115
if ( opts.series ) {
115116
opts.limit = 1;
@@ -130,10 +131,10 @@ function factory( options, predicate ) {
130131
*/
131132
function anyByRightAsync( collection, done ) {
132133
if ( !isCollection( collection ) ) {
133-
throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' );
134+
throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) );
134135
}
135136
if ( !isFunction( done ) ) {
136-
throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' );
137+
throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) );
137138
}
138139
return limit( collection, opts, f, clbk );
139140

lib/node_modules/@stdlib/utils/async/bifurcate-by/lib/factory.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 isCollection = require( '@stdlib/assert/is-collection' );
25+
var format = require( '@stdlib/string/format' );
2526
var PINF = require( '@stdlib/constants/float64/pinf' );
2627
var validate = require( './validate.js' );
2728
var limit = require( './limit.js' );
@@ -105,7 +106,7 @@ function factory( options, predicate ) {
105106
f = options;
106107
}
107108
if ( !isFunction( f ) ) {
108-
throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' );
109+
throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) );
109110
}
110111
if ( opts.series ) {
111112
opts.limit = 1;
@@ -126,10 +127,10 @@ function factory( options, predicate ) {
126127
*/
127128
function bifurcateByAsync( collection, done ) {
128129
if ( !isCollection( collection ) ) {
129-
throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' );
130+
throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) );
130131
}
131132
if ( !isFunction( done ) ) {
132-
throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' );
133+
throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) );
133134
}
134135
return limit( collection, opts, f, clbk );
135136

0 commit comments

Comments
 (0)