diff --git a/lib/assign.js b/lib/assign.js index 0344921..229fb4e 100644 --- a/lib/assign.js +++ b/lib/assign.js @@ -23,7 +23,7 @@ var isComplexLike = require( '@stdlib/assert-is-complex-like' ); var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var isnan = require( '@stdlib/math-base-assert-is-nan' ); var dtype = require( '@stdlib/complex-dtype' ); var adtype = require( '@stdlib/array-dtype' ); @@ -76,13 +76,13 @@ function linspace( start, stop, out ) { dt1 = dtype( start ); if ( dt1 === null ) { if ( !isComplexLike( start ) ) { - throw new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) ); + throw new TypeError( format( '0132j', start ) ); } dt1 = 'complex128'; } flg = true; } else if ( !isNumber( start ) || isnan( start ) ) { - throw new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) ); + throw new TypeError( format( '0132j', start ) ); } else { dt1 = 'float64'; } @@ -90,18 +90,18 @@ function linspace( start, stop, out ) { dt2 = dtype( stop ); if ( dt2 === null ) { if ( !isComplexLike( stop ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) ); + throw new TypeError( format( '0132k', stop ) ); } dt2 = 'complex128'; } flg = true; } else if ( !isNumber( stop ) || isnan( stop ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) ); + throw new TypeError( format( '0132k', stop ) ); } else { dt2 = 'float64'; } if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an array-like object. Value: `%s`.', out ) ); + throw new TypeError( format( '0132l', out ) ); } opts = { 'endpoint': defaults.endpoint @@ -130,7 +130,7 @@ function linspace( start, stop, out ) { acccmplx( o, dt1, start, dt2, stop, out.length, opts.endpoint ); return out; } - throw new TypeError( 'invalid arguments. If either of the first two arguments are complex numbers, the output array must be a complex number array or a "generic" array-like object.' ); + throw new TypeError( format('01307') ); } o = arraylike2object( out ); if ( o.accessorProtocol ) { diff --git a/lib/main.js b/lib/main.js index a3aa0e3..6b148e7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -29,7 +29,7 @@ var ctors = require( '@stdlib/array-typed-float-ctors' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); var DEFAULTS = require( '@stdlib/array-defaults' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var genreal = require( './generic_real.js' ); var gencmplx = require( './generic_complex.js' ); var typedreal = require( './typed_real.js' ); @@ -82,13 +82,13 @@ function linspace( start, stop, len ) { dt1 = dtype( start ); if ( dt1 === null ) { if ( !isComplexLike( start ) ) { - throw new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) ); + throw new TypeError( format( '0132j', start ) ); } dt1 = 'complex128'; } flg = true; } else if ( !isNumber( start ) || isnan( start ) ) { - throw new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) ); + throw new TypeError( format( '0132j', start ) ); } else { dt1 = 'float64'; } @@ -96,18 +96,18 @@ function linspace( start, stop, len ) { dt2 = dtype( stop ); if ( dt2 === null ) { if ( !isComplexLike( stop ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) ); + throw new TypeError( format( '0132k', stop ) ); } dt2 = 'complex128'; } flg = true; } else if ( !isNumber( stop ) || isnan( stop ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) ); + throw new TypeError( format( '0132k', stop ) ); } else { dt2 = 'float64'; } if ( !isNonNegativeInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%s`.', len ) ); + throw new TypeError( format( '0132m', len ) ); } opts = { 'endpoint': defaults.endpoint @@ -132,7 +132,7 @@ function linspace( start, stop, len ) { } ctor = ctors( opts.dtype ); if ( ctor === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a real or complex floating-point data type or "generic". Option: `%s`.', 'dtype', opts.dtype ) ); + throw new TypeError( format( '0132n', 'dtype', opts.dtype ) ); } out = new ctor( len ); if ( opts.dtype === 'complex64' ) { @@ -144,7 +144,7 @@ function linspace( start, stop, len ) { return out; } if ( flg ) { - throw new TypeError( 'invalid arguments. If either of the first two arguments are complex numbers, the output array data type must be a complex number data type or "generic".' ); + throw new TypeError( format('01308') ); } return typedreal( out, start, stop, len, opts.endpoint ); } diff --git a/lib/validate.js b/lib/validate.js index f0a3b3d..03f4591 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -24,7 +24,7 @@ var isObject = require( '@stdlib/assert-is-plain-object' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -51,18 +51,18 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0132V', options ) ); } if ( hasOwnProp( options, 'dtype' ) ) { opts.dtype = options.dtype; if ( !isString( opts.dtype ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'dtype', opts.dtype ) ); + return new TypeError( format( '0132W', 'dtype', opts.dtype ) ); } } if ( hasOwnProp( options, 'endpoint' ) ) { opts.endpoint = options.endpoint; if ( !isBoolean( opts.endpoint ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'endpoint', opts.endpoint ) ); + return new TypeError( format( '0132o', 'endpoint', opts.endpoint ) ); } } return null; diff --git a/package.json b/package.json index 3a8eff2..2c8fcc2 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "@stdlib/math-base-assert-is-nan": "^0.2.2", "@stdlib/strided-base-reinterpret-complex128": "^0.2.2", "@stdlib/strided-base-reinterpret-complex64": "^0.2.1", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2"