Skip to content

Commit a2a00c4

Browse files
committed
Transform error messages
1 parent 007c6f5 commit a2a00c4

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/main.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var MultiSlice = require( '@stdlib/slice-multi' );
3131
var args2multislice = require( '@stdlib/slice-base-args2multislice' );
3232
var base = require( '@stdlib/ndarray-base-slice-assign' );
3333
var getShape = require( '@stdlib/ndarray-shape' );
34-
var format = require( '@stdlib/string-format' );
34+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
3535

3636

3737
// MAIN //
@@ -116,38 +116,38 @@ function sliceAssign( x, y, s ) {
116116
};
117117
nargs = arguments.length;
118118
if ( !isndarrayLike( x ) ) {
119-
throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );
119+
throw new TypeError( format( '1jT4f', x ) );
120120
}
121121
if ( !isndarrayLike( y ) ) {
122-
throw new TypeError( format( 'invalid argument. Second argument must be an ndarray. Value: `%s`.', y ) );
122+
throw new TypeError( format( '1jTF1', y ) );
123123
}
124124
if ( isReadOnly( y ) ) {
125-
throw new Error( 'invalid argument. Cannot write to a read-only array.' );
125+
throw new Error( format('1jTEs') );
126126
}
127127
if ( isPlainObject( arguments[ nargs-1 ] ) ) {
128128
nargs -= 1;
129129
options = arguments[ nargs ];
130130
if ( hasOwnProp( options, 'strict' ) ) {
131131
if ( !isBoolean( options.strict ) ) {
132-
throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );
132+
throw new TypeError( format( '1jT2o', 'strict', options.strict ) );
133133
}
134134
opts.strict = options.strict;
135135
}
136136
sh = getShape( y );
137137
if ( nargs === 2 && sh.length > 0 ) {
138-
throw new RangeError( format( 'invalid argument. Number of slice dimensions does not match the number of array dimensions. Array shape: (%s). Slice dimensions: %u.', sh.join( ',' ), 0 ) );
138+
throw new RangeError( format( '1jTEt', sh.join( ',' ), 0 ) );
139139
}
140140
}
141141
if ( isMultiSlice( s ) ) {
142142
S = s;
143143
if ( nargs > 3 ) {
144-
throw new Error( 'invalid invocation. Too many arguments.' );
144+
throw new Error( format('1jT0m') );
145145
}
146146
} else {
147147
if ( isArrayLikeObject( s ) ) {
148148
args = s;
149149
if ( nargs > 3 ) {
150-
throw new Error( 'invalid invocation. Too many arguments.' );
150+
throw new Error( format('1jT0m') );
151151
}
152152
} else {
153153
args = [];
@@ -163,7 +163,7 @@ function sliceAssign( x, y, s ) {
163163
try {
164164
new MultiSlice( args[ i ] ); // eslint-disable-line no-new
165165
} catch ( err ) { // eslint-disable-line no-unused-vars
166-
throw new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );
166+
throw new TypeError( format( '1jTEu', String( args[ i ] ) ) );
167167
}
168168
}
169169
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@stdlib/ndarray-shape": "^0.2.2",
4949
"@stdlib/slice-base-args2multislice": "^0.2.2",
5050
"@stdlib/slice-multi": "^0.2.2",
51-
"@stdlib/string-format": "^0.2.2",
51+
"@stdlib/error-tools-fmtprodmsg": "^0.2.2",
5252
"@stdlib/types": "^0.4.3",
5353
"@stdlib/error-tools-fmtprodmsg": "^0.2.2"
5454
},

0 commit comments

Comments
 (0)