diff --git a/lib/main.js b/lib/main.js index 0b0db1b..445085b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -62,7 +62,7 @@ var defaults = require( '@stdlib/ndarray-defaults' ); var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); @@ -299,10 +299,10 @@ function Random( prng, idtypes, odtypes, policies, options ) { return new Random( prng, idtypes, odtypes, policies, options ); } if ( !isFunction( prng ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', prng ) ); + throw new TypeError( format( 'null3c', prng ) ); } if ( !isCollection( idtypes ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', idtypes ) ); + throw new TypeError( format( 'null2y', idtypes ) ); } idtypes = copy( idtypes ); for ( i = 0; i < idtypes.length; i++ ) { @@ -326,7 +326,7 @@ function Random( prng, idtypes, odtypes, policies, options ) { odtypes = dtypes2strings( odtypes ); if ( !isObject( policies ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be an object. Value: `%s`.', policies ) ); + throw new TypeError( format( 'null43', policies ) ); } if ( !isOutputDataTypePolicy( policies.output ) ) { throw new TypeError( format( 'invalid argument. Fourth argument must be an object having a supported output data type policy. Value: `%s`.', policies.output ) ); @@ -336,7 +336,7 @@ function Random( prng, idtypes, odtypes, policies, options ) { }; if ( arguments.length > 4 ) { if ( !isPlainObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } if ( hasOwnProp( options, 'order' ) ) { opts.order = options.order; @@ -414,7 +414,7 @@ setReadOnly( Random.prototype, 'generate', function generate( shape, param1, par var i; if ( !isNonNegativeIntegerArray( shape ) && !isEmptyCollection( shape ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object containing nonnegative integers. Value: `%s`.', shape ) ); + throw new TypeError( format( 'null5o', shape ) ); } opts = {}; if ( arguments.length > 3 ) { @@ -557,7 +557,7 @@ setReadOnly( Random.prototype, 'assign', function assign( param1, param2, out ) throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', out ) ); } if ( isReadOnly( out ) ) { - throw new Error( 'invalid argument. The output ndarray must be writable. Cannot write to a read-only ndarray.' ); + throw new Error( format('null1g') ); } sh = getShape( out ); ord = getOrder( out ); diff --git a/lib/validate.js b/lib/validate.js index 6ed34d2..27724b9 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var contains = require( '@stdlib/array-base-assert-contains' ); var join = require( '@stdlib/array-base-join' ); var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -58,12 +58,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, dtypes, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { opts.dtype = resolveStr( options.dtype ); if ( !contains( dtypes, opts.dtype ) ) { - return new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'dtype', join( dtypes, '", "' ), options.dtype ) ); + return new TypeError( format( 'null4S', 'dtype', join( dtypes, '", "' ), options.dtype ) ); } } // Pass-through options... diff --git a/package.json b/package.json index 02f652f..15dc42d 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "@stdlib/ndarray-order": "^0.2.3", "@stdlib/ndarray-shape": "^0.2.3", "@stdlib/strided-base-nullary": "^0.3.1", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/types": "^0.5.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3"