Skip to content

Commit 6b9fcc9

Browse files
committed
Format error messages
1 parent a46312b commit 6b9fcc9

File tree

27 files changed

+74
-51
lines changed

27 files changed

+74
-51
lines changed

lib/node_modules/@stdlib/datasets/cmudict/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 resolve = require( 'path' ).resolve;
24+
var format = require( '@stdlib/string/format' );
2425
var readJSON = require( '@stdlib/fs/read-json' ).sync;
2526
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
2627
var validate = require( './validate.js' );
@@ -84,7 +85,7 @@ function cmudict( options ) {
8485
}
8586
if ( opts.data ) {
8687
if ( !hasOwnProp( dataCMU, opts.data ) ) {
87-
throw new RangeError( 'invalid option. `data` option must be one of the following values: `'+keys.join(',')+'`. Option: `'+opts.data+'`.' );
88+
throw new RangeError( format( 'invalid option. `%s` option must be one of the following: `%s`. Option: `%s`.', 'data', keys.join(','), opts.data ) );
8889
}
8990
out = readJSON( dataCMU[ opts.data ], fopts );
9091
if ( out instanceof Error ) {

lib/node_modules/@stdlib/datasets/minard-napoleons-march/lib/browser.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 hasOwnProp = require( '@stdlib/assert/has-own-property' );
26+
var format = require( '@stdlib/string/format' );
2627
var validate = require( './validate.js' );
2728
var minardData = require( './data.js' );
2829

@@ -61,7 +62,7 @@ function minard( options ) {
6162
}
6263
if ( opts.data ) {
6364
if ( !hasOwnProp( minardData, opts.data ) ) {
64-
throw new RangeError( 'invalid option. `data` option must be one of the following values: `'+objectKeys( minardData ).join(',')+'`. Option: `'+opts.data+'`.' );
65+
throw new RangeError( format( 'invalid option. `%s` option must be one of the following: `%s`. Option: `%s`.', 'data', objectKeys( minardData ).join(','), opts.data ) );
6566
}
6667
return copy( minardData[ opts.data ] );
6768
}

lib/node_modules/@stdlib/iter/flow/lib/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ function iterFlow( methods ) {
217217
k = keys[ i ];
218218
f = methods[ k ];
219219
if ( !isFunction( f ) ) {
220-
throw new TypeError( 'invalid argument. Object property values must be functions. Key: `' + k + '`. Value: `' + f + '`.' );
220+
throw new TypeError( format( 'invalid argument. Object property values must be functions. Key: `%s`. Value: `%s`.', k, f ) );
221221
}
222222
setNonEnumerableReadOnly( FluentIterator.prototype, k, createMethod( f ) ); // eslint-disable-line max-len
223223
}

lib/node_modules/@stdlib/ndarray/base/bind2vind/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 trunc = require( '@stdlib/math/base/special/trunc' );
2425
var abs = require( '@stdlib/math/base/special/abs' );
2526

@@ -83,7 +84,7 @@ function bind2vind( shape, strides, offset, order, idx, mode ) {
8384
}
8485
}
8586
} else if ( idx < 0 || idx >= len ) {
86-
throw new RangeError( 'invalid argument. Linear index must not exceed array dimensions. Number of array elements: ' + len + '. Value: `' + idx + '`.' );
87+
throw new RangeError( format( 'invalid argument. Linear index must not exceed array dimensions. Number of array elements: `%u`. Value: `%u`.', len, idx ) );
8788
}
8889
// The approach which follows is to resolve a buffer index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the array view (i.e., where all strides are positive and offset is 0)...
8990
ind = 0;

lib/node_modules/@stdlib/ndarray/base/ind2sub/lib/assign.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 trunc = require( '@stdlib/math/base/special/trunc' );
2425

2526

@@ -85,7 +86,7 @@ function ind2sub( shape, strides, offset, order, idx, mode, out ) {
8586
}
8687
}
8788
} else if ( idx < 0 || idx >= len ) {
88-
throw new RangeError( 'invalid argument. Linear index must not exceed array dimensions. Number of array elements: ' + len + '. Value: `' + idx + '`.' );
89+
throw new RangeError( format( 'invalid argument. Linear index must not exceed array dimensions. Number of array elements: `%u`. Value: `%d`.', len, idx ) );
8990
}
9091
if ( offset === 0 ) {
9192
if ( order === 'column-major' ) {

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

1919
'use strict';
2020

21+
// MODULES //
22+
23+
var format = require( '@stdlib/string/format' );
24+
25+
2126
// MAIN //
2227

2328
/**
@@ -76,7 +81,7 @@ function vind2bind( shape, strides, offset, order, idx, mode ) {
7681
}
7782
}
7883
} else if ( idx < 0 || idx >= len ) {
79-
throw new RangeError( 'invalid argument. Linear index must not exceed array dimensions. Number of array elements: ' + len + '. Value: `' + idx + '`.' );
84+
throw new RangeError( format( 'invalid argument. Linear index must not exceed array dimensions. Number of array elements: `%u`. Value: `%u`.', len, idx ) );
8085
}
8186
// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...
8287
ind = offset;

lib/node_modules/@stdlib/plot/base/ctor/lib/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function Plot() {
223223
options = {};
224224
} else if ( nargs > 2 ) {
225225
if ( !isObject( arguments[ 2 ] ) ) {
226-
throw new TypeError( 'invalid argument. Options argument must be an `object`. Value: `' + arguments[2] + '`.' );
226+
throw new TypeError( format( 'invalid argument. Options argument must be an `object`. Value: `%s`.', arguments[2] ) );
227227
}
228228
options = copy( arguments[ 2 ] ); // avoid mutation
229229
}

lib/node_modules/@stdlib/plot/base/ctor/lib/props/engine/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 contains = require( '@stdlib/assert/contains' );
25+
var format = require( '@stdlib/string/format' );
2526
var ENGINES = require( './engines.json' );
2627

2728

@@ -42,7 +43,7 @@ var debug = logger( 'plot:base:set:engine' );
4243
function set( engine ) {
4344
/* eslint-disable no-invalid-this */
4445
if ( !contains( ENGINES, engine ) ) {
45-
throw new TypeError( 'invalid value. `engine` must be one of `[' + ENGINES.join( ', ' ) + ']`. Value: `' + engine + '.`' );
46+
throw new TypeError( format( 'invalid value. `%s` must be one of `[%s]`. Value: `%s`.', 'engine', ENGINES.join( ', ' ), engine ) );
4647
}
4748
if ( engine !== this._engine ) {
4849
debug( 'Current value: %s.', this._engine );

lib/node_modules/@stdlib/plot/base/ctor/lib/props/render-format/set.js

Lines changed: 7 additions & 6 deletions
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 FORMATS = require( './formats.json' );
2627

2728

@@ -36,18 +37,18 @@ var debug = logger( 'plot:base:set:render-format' );
3637
* Sets the render format.
3738
*
3839
* @private
39-
* @param {string} format - format
40+
* @param {string} fmt - format
4041
* @throws {TypeError} must be a recognized render format
4142
*/
42-
function set( format ) {
43+
function set( fmt ) {
4344
/* eslint-disable no-invalid-this */
44-
if ( indexOf( FORMATS, format ) === -1 ) {
45-
throw new TypeError( 'invalid value. Unrecognized/unsupported `format`. Must be one of `[' + FORMATS.join( ', ' ) + ']`. Value: `' + format + '.`' );
45+
if ( indexOf( FORMATS, fmt ) === -1 ) {
46+
throw new TypeError( format( 'invalid value. Unrecognized/unsupported `%s`. Must be one of `[%s]`. Value: `%s`.', 'format', FORMATS.join( ', ' ), fmt ) );
4647
}
47-
if ( format !== this._renderFormat ) {
48+
if ( fmt !== this._renderFormat ) {
4849
debug( 'Current value: %s.', this._renderFormat );
4950

50-
this._renderFormat = format;
51+
this._renderFormat = fmt;
5152
debug( 'New value: %s.', this._renderFormat );
5253

5354
this.emit( 'change' );

lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-axis-orient/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 ORIENTATIONS = require( './orientations.json' );
2627

2728

@@ -42,7 +43,7 @@ var debug = logger( 'plot:base:set:x-axis-orient' );
4243
function set( orientation ) {
4344
/* eslint-disable no-invalid-this */
4445
if ( indexOf( ORIENTATIONS, orientation ) === -1 ) {
45-
throw new TypeError( 'invalid value. `xAxisOrient` must be one of `[' + ORIENTATIONS.join( ', ' ) + ']`. Value: `' + orientation + '.`' );
46+
throw new TypeError( format( 'invalid value. `%s` must be one of `[%s]`. Value: `%s`.', 'xAxisOrient', ORIENTATIONS.join( ', ' ), orientation ) );
4647
}
4748
if ( orientation !== this._xAxisOrient ) {
4849
debug( 'Current value: %s.', this._xAxisOrient );

0 commit comments

Comments
 (0)