Skip to content

Commit 27e9dd4

Browse files
committed
Transform error messages
1 parent 81b56b3 commit 27e9dd4

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

lib/get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;
2626
var getIndex = require( '@stdlib/ndarray-base-ind' );
27-
var format = require( '@stdlib/string-format' );
27+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
2828

2929

3030
// MAIN //

lib/iget.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;
2626
var getIndex = require( '@stdlib/ndarray-base-ind' );
2727
var parent = require( '@stdlib/ndarray-base-ctor' ); // eslint-disable-line stdlib/no-redeclare
28-
var format = require( '@stdlib/string-format' );
28+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
2929

3030

3131
// VARIABLES //

lib/iset.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;
2626
var getIndex = require( '@stdlib/ndarray-base-ind' );
2727
var parent = require( '@stdlib/ndarray-base-ctor' ); // eslint-disable-line stdlib/no-redeclare
28-
var format = require( '@stdlib/string-format' );
28+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
2929

3030

3131
// VARIABLES //
@@ -52,7 +52,7 @@ var base = parent.prototype.iset;
5252
*/
5353
function iset( idx, v ) {
5454
if ( this._flags.READONLY ) {
55-
throw new Error( 'invalid invocation. Cannot write to a read-only array.' );
55+
throw new Error( format( '0Mp0e' ) );
5656
}
5757
if ( this._ndims > 0 ) {
5858
if ( !isInteger( idx ) ) {

lib/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var numel = require( '@stdlib/ndarray-base-numel' );
3535
var parent = require( '@stdlib/ndarray-base-ctor' ); // eslint-disable-line stdlib/no-redeclare
3636
var defaults = require( '@stdlib/ndarray-defaults' );
3737
var inherit = require( '@stdlib/utils-inherit' );
38-
var format = require( '@stdlib/string-format' );
38+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
3939
var iget = require( './iget.js' );
4040
var iset = require( './iset.js' );
4141
var get = require( './get.js' );
@@ -144,7 +144,7 @@ function ndarray( dtype, buffer, shape, strides, offset, order, options ) {
144144
throw new RangeError( format( 'invalid argument. Fourth argument must contain a single element equal to 0. Value: `%d`.', strides[ 0 ] ) );
145145
}
146146
if ( !isNonNegativeInteger( offset ) ) {
147-
throw new TypeError( format( 'invalid argument. Fifth argument must be a nonnegative integer. Value: `%s`.', offset ) );
147+
throw new TypeError( format( '0Mp5v', offset ) );
148148
}
149149
if ( !isOrder( order ) ) {
150150
throw new TypeError( format( 'invalid argument. Sixth argument must be a supported order. Value: `%s`.', order ) );

lib/set.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;
2626
var getIndex = require( '@stdlib/ndarray-base-ind' );
27-
var format = require( '@stdlib/string-format' );
27+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
2828

2929

3030
// MAIN //
@@ -52,7 +52,7 @@ function set() {
5252
var i;
5353

5454
if ( this._flags.READONLY ) {
55-
throw new Error( 'invalid invocation. Cannot write to a read-only array.' );
55+
throw new Error( format( '0Mp0e' ) );
5656
}
5757
if ( arguments.length !== this._ndims+1 ) {
5858
throw new RangeError( format( 'invalid arguments. Number of indices must match the number of dimensions. ndims: `%u`. nargs: `%u`.', this._ndims, arguments.length ) );

lib/validate.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' );
2525
var isArray = require( '@stdlib/assert-is-array' );
2626
var isIndexMode = require( '@stdlib/ndarray-base-assert-is-index-mode' );
2727
var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;
28-
var format = require( '@stdlib/string-format' );
28+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
2929

3030

3131
// MAIN //
@@ -55,21 +55,21 @@ var format = require( '@stdlib/string-format' );
5555
function validate( opts, options ) {
5656
var i;
5757
if ( !isObject( options ) ) {
58-
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
58+
return new TypeError( format( '0Mp2h', options ) );
5959
}
6060
if ( hasOwnProp( options, 'mode' ) ) {
6161
opts.mode = options.mode;
6262
if ( !isIndexMode( opts.mode ) ) {
63-
return new TypeError( format( 'invalid option. `%s` option must be a recognized mode. Option: `%s`.', 'mode', opts.mode ) );
63+
return new TypeError( format( '0Mp5o', 'mode', opts.mode ) );
6464
}
6565
}
6666
if ( hasOwnProp( options, 'submode' ) ) {
6767
opts.submode = options.submode;
6868
if ( !isArray( opts.submode ) ) {
69-
return new TypeError( format( 'invalid option. `%s` option must be an array containing recognized modes. Option: `%s`.', 'submode', opts.submode ) );
69+
return new TypeError( format( '0Mp5p', 'submode', opts.submode ) );
7070
}
7171
if ( opts.submode.length === 0 ) {
72-
return new TypeError( format( 'invalid option. `%s` option must be an array containing recognized modes. Option: `%s`.', 'submode', opts.submode.join( ',' ) ) );
72+
return new TypeError( format( '0Mp5p', 'submode', opts.submode.join( ',' ) ) );
7373
}
7474
for ( i = 0; i < opts.submode.length; i++ ) {
7575
if ( !isIndexMode( opts.submode[ i ] ) ) {
@@ -81,7 +81,7 @@ function validate( opts, options ) {
8181
if ( hasOwnProp( options, 'readonly' ) ) {
8282
opts.readonly = options.readonly;
8383
if ( !isBoolean( opts.readonly ) ) {
84-
return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readonly', opts.readonly ) );
84+
return new TypeError( format( '0Mp30', 'readonly', opts.readonly ) );
8585
}
8686
}
8787
return null;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"@stdlib/ndarray-dtypes": "^0.0.9",
6868
"@stdlib/ndarray-index-modes": "^0.0.8",
6969
"@stdlib/ndarray-orders": "^0.0.8",
70-
"@stdlib/string-format": "^0.0.3",
70+
"@stdlib/error-tools-fmtprodmsg": "^0.0.2",
7171
"@stdlib/types": "^0.0.14",
7272
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7",
7373
"@stdlib/utils-inherit": "^0.0.8",

0 commit comments

Comments
 (0)