Skip to content

Commit a46312b

Browse files
committed
Format error messages
1 parent df1f8b4 commit a46312b

File tree

30 files changed

+62
-37
lines changed

30 files changed

+62
-37
lines changed

lib/node_modules/@stdlib/_tools/github/rank-users/lib/analyze.js

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

2323
var pluck = require( '@stdlib/utils/pluck' );
24+
var format = require( '@stdlib/string/format' );
2425
var methods = require( './methods.json' );
2526
var raw = require( './pluck.raw.js' );
2627
var ratio = require( './pluck.ratio.js' );
@@ -61,7 +62,7 @@ function analyze( data, opts, clbk ) {
6162
tmp = ratio( data, params.key1, params.key2 );
6263
break;
6364
default:
64-
throw new TypeError( 'unknown method option. Option: `' + opts.method + '`.' );
65+
throw new TypeError( format( 'unknown method option. Option: `%s`.', opts.method ) );
6566
}
6667
// For `created`, older users should be ranked higher...
6768
if ( opts.method === 'created' ) {

lib/node_modules/@stdlib/_tools/github/user-details/lib/validate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function validate( opts, options ) {
4545
}
4646
opts.usernames = options.usernames;
4747
if ( !isStringArray( opts.usernames ) ) {
48-
return new TypeError( 'invalid option. Usernames option must be a string array. Option: `' + opts.usernames + '`.' );
48+
return new TypeError( format( 'invalid option. `%s` option must be a string array. Option: `%s`.', 'usernames', opts.usernames ) );
4949
}
5050
if ( hasOwnProp( options, 'token' ) ) {
5151
opts.token = options.token;

lib/node_modules/@stdlib/array/convert-same/lib/main.js

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

2323
var getType = require( '@stdlib/array/dtype' );
2424
var convert = require( '@stdlib/array/convert' );
25+
var format = require( '@stdlib/string/format' );
2526

2627

2728
// MAIN //
@@ -47,7 +48,7 @@ var convert = require( '@stdlib/array/convert' );
4748
function convertSame( x, y ) {
4849
var dtype = getType( y );
4950
if ( dtype === null ) {
50-
throw new TypeError( 'invalid argument. Second argument must have a recognized/supported data type. Type: `' + dtype + '`. Value: `' + y + '`.' );
51+
throw new TypeError( format( 'invalid argument. Second argument must have a recognized/supported data type. Type: `%s`. Value: `%s`.', dtype, y ) );
5152
}
5253
return convert( x, dtype );
5354
}

lib/node_modules/@stdlib/array/linspace/lib/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function linspace( start, stop, len ) {
126126
}
127127
ctor = ctors( opts.dtype );
128128
if ( ctor === null ) {
129-
throw new TypeError( 'invalid argument. `dtype` option must be a real or complex floating-point data type or "generic". Option: `' + opts.dtype + '`.' );
129+
throw new TypeError( format( 'invalid argument. `%s` option must be a real or complex floating-point data type or "generic". Option: `%s`.', 'dtype', opts.dtype ) );
130130
}
131131
out = new ctor( len );
132132
if ( opts.dtype === 'complex64' ) {

lib/node_modules/@stdlib/datasets/lib/datasets.js

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

2323
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
24+
var format = require( '@stdlib/string/format' );
2425
var data = require( './data.js' );
2526

2627

@@ -45,7 +46,7 @@ function datasets( name ) {
4546
if ( hasOwnProp( data, name ) ) {
4647
return data[ name ].apply( null, args );
4748
}
48-
throw new RangeError( 'invalid value. Unsupported/unrecognized dataset name. Value: `'+name+'`.' );
49+
throw new RangeError( format( 'invalid value. Unsupported/unrecognized dataset name. Value: `%s`.', name ) );
4950
}
5051

5152

lib/node_modules/@stdlib/iter/replicate-by/lib/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function iterReplicateBy( iterator, fcn, thisArg ) {
125125
j += 1;
126126
n = fcn.call( thisArg, value, j, t );
127127
if ( !isInteger( n ) ) {
128-
throw new TypeError( 'invalid return value. Callback function must return an integer. Value: `' + n + '`.' );
128+
throw new TypeError( format( 'invalid return value. Callback function must return an integer. Value: `%s`.', n ) );
129129
}
130130
i = 0; // reset the counter
131131
if ( n > 0 ) {

lib/node_modules/@stdlib/ndarray/base/ind/lib/main.js

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

2323
var clampIndex = require( '@stdlib/ndarray/base/clamp-index' );
2424
var wrapIndex = require( '@stdlib/ndarray/base/wrap-index' );
25+
var format = require( '@stdlib/string/format' );
2526

2627

2728
// MAIN //
@@ -73,7 +74,7 @@ function ind( idx, max, mode ) {
7374
return wrapIndex( idx, max );
7475
}
7576
if ( idx < 0 || idx > max ) {
76-
throw new RangeError( 'invalid argument. Index must be on the interval: [0,' + max + ']. Value: `' + idx + '`.' );
77+
throw new RangeError( format( 'invalid argument. Index must be on the interval: [0,%f]. Value: `%f`.', max, idx ) );
7778
}
7879
return idx;
7980
}

lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-opacity/set.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var logger = require( 'debug' );
2424
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
2525
var isNumberArray = require( '@stdlib/assert/is-number-array' ).primitives;
26+
var format = require( '@stdlib/string/format' );
2627

2728

2829
// VARIABLES //
@@ -45,7 +46,7 @@ function set( v ) {
4546
var isNum = isNumber( v );
4647
var i;
4748
if ( !isNum && !isNumberArray( v ) ) {
48-
throw new TypeError( 'invalid value. `lineOpacity` must be a number or number array. Value: `' + v + '.`' );
49+
throw new TypeError( format( 'invalid value. `%s` must be a number or number array. Value: `%s`.', 'lineOpacity', v ) );
4950
}
5051
if ( isNum ) {
5152
v = [ v ];
@@ -54,7 +55,7 @@ function set( v ) {
5455
}
5556
for ( i = 0; i < v.length; i++ ) {
5657
if ( v[ i ] < 0.0 || v[ i ] > 1.0 ) {
57-
throw new RangeError( 'invalid value. A `lineOpacity` must be a number on the interval `[0,1]`. Value: `' + v[i] + '`.' );
58+
throw new RangeError( format( 'invalid value. A `%s` must be a number on the interval `[0,1]`. Value: `%f`.', 'lineOpacity', v[i] ) );
5859
}
5960
}
6061
debug( 'Current value: %s.', JSON.stringify( this._lineOpacity ) );

lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-style/set.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var logger = require( 'debug' );
2424
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2525
var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives;
26+
var format = require( '@stdlib/string/format' );
2627
var indexOf = require( '@stdlib/utils/index-of' );
2728
var LINESTYLES = require( './line_styles.json' );
2829

@@ -47,7 +48,7 @@ function set( v ) {
4748
var isStr = isString( v );
4849
var i;
4950
if ( !isStr && !isStringArray( v ) ) {
50-
throw new TypeError( 'invalid value. `lineStyle` must be a string or a string array. Value: `'+v+'.`' );
51+
throw new TypeError( format( 'invalid value. `%s` must be a string or a string array. Value: `%s`', 'lineStyle', v ) );
5152
}
5253
if ( isStr ) {
5354
v = [ v ];
@@ -56,7 +57,7 @@ function set( v ) {
5657
}
5758
for ( i = 0; i < v.length; i++ ) {
5859
if ( indexOf( LINESTYLES, v[i] ) === -1 ) {
59-
throw new Error( 'invalid value. Unsupported/unrecognized line style. Must be one of `['+LINESTYLES.join(',')+']`. Value: `'+v[i]+'`.' );
60+
throw new Error( format( 'invalid value. Unsupported/unrecognized line style. Must be one of `[%s]`. Value: `%s`.', LINESTYLES.join(','), v[i] ) );
6061
}
6162
}
6263
debug( 'Current value: %s.', JSON.stringify( this._lineStyle ) );

lib/node_modules/@stdlib/plot/components/svg/symbols/lib/props/symbol/set.js

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

2323
var logger = require( 'debug' );
2424
var indexOf = require( '@stdlib/utils/index-of' );
25+
var format = require( '@stdlib/string/format' );
2526
var SYMBOLS = require( './symbols.json' );
2627

2728

@@ -42,7 +43,7 @@ var debug = logger( 'symbols:set:symbol' );
4243
function set( symbol ) {
4344
/* eslint-disable no-invalid-this */
4445
if ( indexOf( SYMBOLS, symbol ) === -1 ) {
45-
throw new TypeError( 'invalid value. `symbol` must be a supported symbol. Symbols: ['+SYMBOLS.join(',')+']. Value: `'+symbol+'`.' );
46+
throw new TypeError( format( 'invalid value. `%s` must be a supported symbol. Symbols: [%s]. Value: `%s`.', 'symbol', SYMBOLS.join(','), symbol ) );
4647
}
4748
debug( 'Current value: %d.', this._symbol );
4849

0 commit comments

Comments
 (0)