From 6ec6ae91efe0497c3e69a9871446ef4f202cac5e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 01:25:50 +0000 Subject: [PATCH] Transform error messages --- lib/main.js | 12 ++++++------ package.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/main.js b/lib/main.js index f5588e2..d071963 100644 --- a/lib/main.js +++ b/lib/main.js @@ -30,7 +30,7 @@ var isUndefined = require( '@stdlib/assert-is-undefined' ); var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var getShape = require( '@stdlib/ndarray-shape' ); var base = require( '@stdlib/ndarray-base-slice-from' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -118,26 +118,26 @@ function sliceFrom( x, start ) { }; nargs = arguments.length; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) ); + throw new TypeError( format( '1mx4f', x ) ); } if ( isPlainObject( arguments[ nargs-1 ] ) ) { nargs -= 1; options = arguments[ nargs ]; if ( hasOwnProp( options, 'strict' ) ) { if ( !isBoolean( options.strict ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) ); + throw new TypeError( format( '1mx2o', 'strict', options.strict ) ); } opts.strict = options.strict; } sh = getShape( x ); if ( nargs === 1 && sh.length > 0 ) { - throw new RangeError( format( 'invalid argument. Number of indices does not match the number of array dimensions. Array shape: (%s). Number of indices: %u.', sh.join( ',' ), 0 ) ); + throw new RangeError( format( '1mxFE', sh.join( ',' ), 0 ) ); } } if ( isArrayLikeObject( start ) ) { args = start; if ( nargs > 2 ) { - throw new Error( 'invalid invocation. Too many arguments.' ); + throw new Error( format('1mx0m') ); } } else { args = []; @@ -147,7 +147,7 @@ function sliceFrom( x, start ) { } for ( i = 0; i < args.length; i++ ) { if ( isInvalidIndex( args[ i ] ) ) { - throw new TypeError( format( 'invalid argument. Each index argument must be either an integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) ); + throw new TypeError( format( '1mxFF', String( args[ i ] ) ) ); } } return base( x, args, opts.strict, false ); diff --git a/package.json b/package.json index 0129a2b..63aa813 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@stdlib/assert-is-undefined": "^0.2.2", "@stdlib/ndarray-base-slice-from": "^0.2.2", "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" },