Skip to content

Commit 10dbbaa

Browse files
committed
Transform error messages
1 parent 81ac8be commit 10dbbaa

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

lib/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-propert
2424
var iteratorSymbol = require( '@stdlib/symbol-iterator' );
2525
var abs = require( '@stdlib/math-base-special-abs' );
2626
var cospi = require( '@stdlib/math-base-special-cospi' );
27-
var format = require( '@stdlib/string-format' );
27+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
2828
var validate = require( './validate.js' );
2929

3030

@@ -112,10 +112,10 @@ function iterBartlettHannPulse( options ) {
112112
opts.duration = opts.period;
113113
}
114114
if ( opts.duration > opts.period ) {
115-
throw new RangeError( format( 'invalid option. `%s` option must be less than or equal to the period. Option: `%u`.', 'duration', opts.duration ) );
115+
throw new RangeError( format( '0tB8K', 'duration', opts.duration ) );
116116
}
117117
if ( opts.duration <= 2 ) {
118-
throw new RangeError( format( 'invalid option. `%s` option must be greater than 2. Option: `%s`.', 'duration', opts.duration ) );
118+
throw new RangeError( format( '0tB8L', 'duration', opts.duration ) );
119119
}
120120
t = ( opts.period-opts.offset ) % opts.period;
121121
if ( t < 0 ) {

lib/validate.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var isPositiveNumber = require( '@stdlib/assert-is-positive-number' ).isPrimitiv
2626
var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;
2727
var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;
2828
var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;
29-
var format = require( '@stdlib/string-format' );
29+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
3030

3131

3232
// MAIN //
@@ -56,36 +56,36 @@ var format = require( '@stdlib/string-format' );
5656
*/
5757
function validate( opts, options ) {
5858
if ( !isPlainObject( options ) ) {
59-
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
59+
return new TypeError( format( '0tB2V', options ) );
6060
}
6161
if ( hasOwnProp( options, 'duration' ) ) {
6262
opts.duration = options.duration;
6363
if ( !isPositiveInteger( options.duration ) ) {
64-
return new TypeError( format( 'invalid option. `%s` option must be a positive integer. Option: `%s`.', 'duration', options.duration ) );
64+
return new TypeError( format( '0tB3P', 'duration', options.duration ) );
6565
}
6666
}
6767
if ( hasOwnProp( options, 'period' ) ) {
6868
opts.period = options.period;
6969
if ( !isPositiveInteger( options.period ) ) {
70-
return new TypeError( format( 'invalid option. `%s` option must be a positive integer. Option: `%s`.', 'period', options.period ) );
70+
return new TypeError( format( '0tB3P', 'period', options.period ) );
7171
}
7272
}
7373
if ( hasOwnProp( options, 'amplitude' ) ) {
7474
opts.amplitude = options.amplitude;
7575
if ( !isPositiveNumber( options.amplitude ) ) {
76-
return new TypeError( format( 'invalid option. `%s` option must be a positive number. Option: `%s`.', 'amplitude', options.amplitude ) );
76+
return new TypeError( format( '0tB4D', 'amplitude', options.amplitude ) );
7777
}
7878
}
7979
if ( hasOwnProp( options, 'offset' ) ) {
8080
opts.offset = options.offset;
8181
if ( !isInteger( options.offset ) ) {
82-
return new TypeError( format( 'invalid option. `%s` option must be an integer. Option: `%s`.', 'offset', options.offset ) );
82+
return new TypeError( format( '0tB8M', 'offset', options.offset ) );
8383
}
8484
}
8585
if ( hasOwnProp( options, 'iter' ) ) {
8686
opts.iter = options.iter;
8787
if ( !isNonNegativeInteger( options.iter ) ) {
88-
return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', options.iter ) );
88+
return new TypeError( format( '0tB2t', 'iter', options.iter ) );
8989
}
9090
}
9191
return null;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"@stdlib/assert-is-positive-number": "^0.2.2",
4646
"@stdlib/math-base-special-abs": "^0.2.2",
4747
"@stdlib/math-base-special-cospi": "^0.4.0",
48-
"@stdlib/string-format": "^0.2.2",
48+
"@stdlib/error-tools-fmtprodmsg": "^0.2.2",
4949
"@stdlib/symbol-iterator": "^0.2.2",
5050
"@stdlib/types": "^0.4.3",
5151
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",

0 commit comments

Comments
 (0)