8000 Transform error messages · stdlib-js/random-tools-binary@c75686f · GitHub
[go: up one dir, main page]

Skip to content

Commit c75686f

Browse files
committed
Transform error messages
1 parent 4f3e8e4 commit c75686f

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

lib/main.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ var defaults = require( '@stdlib/ndarray-defaults' );
5858
var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );
5959
var accessorSetter = require( '@stdlib/array-base-accessor-setter' );
6060
var setter = require( '@stdlib/array-base-setter' );
61-
var format = require( '@stdlib/string-format' );
61+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
6262
var validate = require( './validate.js' );
6363

6464

@@ -294,10 +294,10 @@ function Random( prng, idtypes, odtypes, policies, options ) {
294294
return new Random( prng, idtypes, odtypes, policies, options );
295295
}
296296
if ( !isFunction( prng ) ) {
297-
throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', prng ) );
297+
throw new TypeError( format( 'null3c', prng ) );
298298
}
299299
if ( !isCollection( idtypes ) ) {
300-
throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', idtypes ) );
300+
throw new TypeError( format( 'null2y', idtypes ) );
301301
}
302302
for ( i = 0; i < idtypes.length; i++ ) {
303303
if (
@@ -316,7 +316,7 @@ function Random( prng, idtypes, odtypes, policies, options ) {
316316
throw new TypeError( format( 'invalid argument. Third argument must be an array of data types. Value: `%s`.', odtypes ) );
317317
}
318318
if ( !isObject( policies ) ) {
319-
throw new TypeError( format( 'invalid argument. Fourth argument must be an object. Value: `%s`.', policies ) );
319+
throw new TypeError( format( 'null43', policies ) );
320320
}
321321
if ( !isOutputDataTypePolicy( policies.output ) ) {
322322
throw new TypeError( format( 'invalid argument. Fourth argument must be an object having a supported output data type policy. Value: `%s`.', policies.output ) );
@@ -326,7 +326,7 @@ function Random( prng, idtypes, odtypes, policies, options ) {
326326
};
327327
if ( arguments.length > 4 ) {
328328
if ( !isPlainObject( options ) ) {
329-
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
329+
throw new TypeError( format( 'null2V', options ) );
330330
}
331331
if ( hasOwnProp( options, 'order' ) ) {
332332
opts.order = options.order;
@@ -404,7 +404,7 @@ setReadOnly( Random.prototype, 'generate', function generate( shape, param1, par
404404
var i;
405405

406406
if ( !isNonNegativeIntegerArray( shape ) && !isEmptyCollection( shape ) ) {
407-
throw new TypeError( format( 'invalid argument. First argument must be an array-like object containing nonnegative integers. Value: `%s`.', shape ) );
407+
throw new TypeError( format( 'null5o', shape ) );
408408
}
409409
opts = {};
410410
if ( arguments.length > 3 ) {
@@ -547,7 +547,7 @@ setReadOnly( Random.prototype, 'assign', function assign( param1, param2, out )
547547
throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', out ) );
548548
}
549549
if ( isReadOnly( out ) ) {
550-
throw new Error( 'invalid argument. The output ndarray must be writable. Cannot write to a read-only ndarray.' );
550+
throw new Error( format('null1g') );
551551
}
552552
sh = getShape( out );
553553
ord = getOrder( out );

lib/validate.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var isObject = require( '@stdlib/assert-is-plain-object' );
2424
var hasOwnProp = require( '@stdlib/assert-has-own-property' );
2525
var contains = require( '@stdlib/array-base-assert-contains' );
2626
var join = require( '@stdlib/array-base-join' );
27-
var format = require( '@stdlib/string-format' );
27+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
2828

2929

3030
// MAIN //
@@ -57,12 +57,12 @@ var format = require( '@stdlib/string-format' );
5757
*/
5858
function validate( opts, dtypes, options ) {
5959
if ( !isObject( options ) ) {
60-
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
60+
return new TypeError( format( 'null2V', options ) );
6161
}
6262
if ( hasOwnProp( options, 'dtype' ) ) {
6363
opts.dtype = options.dtype;
6464
if ( !contains( dtypes, opts.dtype ) ) {
65-
return new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'dtype', join( dtypes, '", "' ), opts.dtype ) );
65+
return new TypeError( format( 'null4S', 'dtype', join( dtypes, '", "' ), opts.dtype ) );
6666
}
6767
}
6868
// Pass-through options...

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"@stdlib/ndarray-order": "^0.2.2",
7373
"@stdlib/ndarray-shape": "^0.2.2",
7474
"@stdlib/strided-base-nullary": "^0.3.0",
75-
"@stdlib/string-format": "^0.2.2",
75+
"@stdlib/error-tools-fmtprodmsg": "^0.2.2",
7676
"@stdlib/types": "^0.4.3",
7777
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
7878
"@stdlib/error-tools-fmtprodmsg": "^0.2.2"

0 commit comments

Comments
 (0)
0