Skip to content

Commit 872610f

Browse files
committed
Transform error messages
1 parent 25e2724 commit 872610f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/main.js

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

3535

3636
// MAIN //
@@ -98,32 +98,32 @@ function slice( x, s ) {
9898
};
9999
nargs = arguments.length;
100100
if ( !isndarrayLike( x ) ) {
101-
throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );
101+
throw new TypeError( format( '1jV4f', x ) );
102102
}
103103
if ( isPlainObject( arguments[ nargs-1 ] ) ) {
104104
nargs -= 1;
105105
options = arguments[ nargs ];
106106
if ( hasOwnProp( options, 'strict' ) ) {
107107
if ( !isBoolean( options.strict ) ) {
108-
throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) );
108+
throw new TypeError( format( '1jV2o', 'strict', options.strict ) );
109109
}
110110
opts.strict = options.strict;
111111
}
112112
sh = getShape( x );
113113
if ( nargs === 1 && sh.length > 0 ) {
114-
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 ) );
114+
throw new RangeError( format( '1jVEt', sh.join( ',' ), 0 ) );
115115
}
116116
}
117117
if ( isMultiSlice( s ) ) {
118118
S = s;
119119
if ( nargs > 2 ) {
120-
throw new Error( 'invalid invocation. Too many arguments.' );
120+
throw new Error( format('1jV0m') );
121121
}
122122
} else {
123123
if ( isArrayLikeObject( s ) ) {
124124
args = s;
125125
if ( nargs > 2 ) {
126-
throw new Error( 'invalid invocation. Too many arguments.' );
126+
throw new Error( format('1jV0m') );
127127
}
128128
} else {
129129
args = [];
@@ -139,7 +139,7 @@ function slice( x, s ) {
139139
try {
140140
new MultiSlice( args[ i ] ); // eslint-disable-line no-new
141141
} catch ( err ) { // eslint-disable-line no-unused-vars
142-
throw new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) );
142+
throw new TypeError( format( '1jVEu', String( args[ i ] ) ) );
143143
}
144144
}
145145
}

package.json

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

0 commit comments

Comments
 (0)