From 9e24afd5855969b3adc4b6bccce1a174abcff9f5 Mon Sep 17 00:00:00 2001
From: stdlib-bot <noreply@stdlib.io>
Date: Sun, 2 Feb 2025 14:47:21 +0000
Subject: [PATCH] Transform error messages

---
 lib/factory.js       |  4 ++--
 lib/get_elements.js  |  2 +-
 lib/prop2array.js    |  2 +-
 lib/prop2slice.js    | 10 +++++-----
 lib/resolve_index.js |  2 +-
 lib/set_elements.js  |  4 ++--
 lib/validate.js      |  6 +++---
 lib/validator.js     | 24 ++++++++++++------------
 package.json         |  2 +-
 9 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/lib/factory.js b/lib/factory.js
index c157b14..95fc9a8 100644
--- a/lib/factory.js
+++ b/lib/factory.js
@@ -25,7 +25,7 @@ var isArrayLike = require( '@stdlib/assert-is-array-like' );
 var Proxy = require( '@stdlib/proxy-ctor' );
 var arraylike2object = require( '@stdlib/array-base-arraylike2object' );
 var assign = require( '@stdlib/object-assign' );
-var format = require( '@stdlib/string-format' );
+var format = require( '@stdlib/error-tools-fmtprodmsg' );
 var setElementWrapper = require( './set_element_wrapper.js' );
 var getArrayWrapper = require( './get_array_wrapper.js' );
 var hasProxySupport = require( './has_proxy_support.js' );
@@ -126,7 +126,7 @@ function factory() {
 		var dt;
 		var o;
 		if ( !isArrayLike( x ) && !isCollection( x ) ) {
-			throw new TypeError( format( 'invalid argument. First argument must be array-like. Value: `%s`.', x ) );
+			throw new TypeError( format( '1rX38', x ) );
 		}
 		if ( hasProxySupport ) {
 			opts = assign( {}, OPTIONS );
diff --git a/lib/get_elements.js b/lib/get_elements.js
index 939d772..23edf3c 100644
--- a/lib/get_elements.js
+++ b/lib/get_elements.js
@@ -23,7 +23,7 @@
 var take = require( '@stdlib/array-take' );
 var mskfilter = require( '@stdlib/array-mskfilter' );
 var mskreject = require( '@stdlib/array-mskreject' );
-var format = require( '@stdlib/string-format' );
+var format = require( '@stdlib/error-tools-fmtprodmsg' );
 var prop2array = require( './prop2array.js' );
 
 
diff --git a/lib/prop2array.js b/lib/prop2array.js
index 6442ea7..c17f6ab 100644
--- a/lib/prop2array.js
+++ b/lib/prop2array.js
@@ -21,7 +21,7 @@
 // MODULES //
 
 var trim = require( '@stdlib/string-base-trim' );
-var format = require( '@stdlib/string-format' );
+var format = require( '@stdlib/error-tools-fmtprodmsg' );
 
 
 // FUNCTIONS //
diff --git a/lib/prop2slice.js b/lib/prop2slice.js
index 6ba9c13..f60a1c0 100644
--- a/lib/prop2slice.js
+++ b/lib/prop2slice.js
@@ -24,7 +24,7 @@ var trim = require( '@stdlib/string-base-trim' );
 var seq2slice = require( '@stdlib/slice-base-seq2slice' );
 var str2slice = require( '@stdlib/slice-base-str2slice' );
 var startsWith = require( '@stdlib/string-base-starts-with' );
-var format = require( '@stdlib/string-format' );
+var format = require( '@stdlib/error-tools-fmtprodmsg' );
 var RE_SUBSEQ = require( './re_subseq.js' );
 
 
@@ -89,7 +89,7 @@ function isSubsequence( prop ) {
 function parseSlice( raw, str ) {
 	var s = str2slice( str );
 	if ( s === null ) {
-		throw new Error( format( 'invalid operation. Unsupported slice operation. Value: `%s`.', raw ) );
+		throw new Error( format( '1rXEn', raw ) );
 	}
 	return s;
 }
@@ -114,15 +114,15 @@ function parseSubsequence( raw, str, max, strict ) {
 	var s = seq2slice( str, max, true );
 	if ( s.code ) {
 		if ( s.code === 'ERR_SLICE_INVALID_INCREMENT' ) {
-			throw new Error( format( 'invalid operation. A subsequence increment must be a non-zero integer. Value: `%s`.', raw ) );
+			throw new Error( format( '1rXEq', raw ) );
 		}
 		if ( s.code === 'ERR_SLICE_INVALID_SUBSEQUENCE' ) {
-			throw new Error( format( 'invalid operation. Unsupported slice operation. Value: `%s`.', raw ) );
+			throw new Error( format( '1rXEn', raw ) );
 		}
 		// NOTE: the following error check must come last due to fall-through when in non-strict mode...
 		if ( s.code === 'ERR_SLICE_OUT_OF_BOUNDS' ) {
 			if ( strict ) {
-				throw new RangeError( format( 'invalid operation. Slice exceeds array bounds.' ) );
+				throw new RangeError( format( '1rXFU' ) );
 			}
 			// Repeat parsing, this time allowing for out-of-bounds slices:
 			s = seq2slice( str, max, false );
diff --git a/lib/resolve_index.js b/lib/resolve_index.js
index 0b5de40..97937c9 100644
--- a/lib/resolve_index.js
+++ b/lib/resolve_index.js
@@ -21,7 +21,7 @@
 // MODULES //
 
 var normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' );
-var format = require( '@stdlib/string-format' );
+var format = require( '@stdlib/error-tools-fmtprodmsg' );
 
 
 // MAIN //
diff --git a/lib/set_elements.js b/lib/set_elements.js
index f33058b..7bcb2f4 100644
--- a/lib/set_elements.js
+++ b/lib/set_elements.js
@@ -30,7 +30,7 @@ var put = require( '@stdlib/array-put' );
 var place = require( '@stdlib/array-place' );
 var convert = require( '@stdlib/array-convert' );
 var where = require( '@stdlib/array-base-where' ).assign;
-var format = require( '@stdlib/string-format' );
+var format = require( '@stdlib/error-tools-fmtprodmsg' );
 var prop2array = require( './prop2array.js' );
 var errMessage = require( './error_message.js' );
 
@@ -106,7 +106,7 @@ function setElements( target, property, value, ctx ) {
 	}
 	// Safe casts are always allowed and allow same kind casts (i.e., downcasts) only when the target array data type is floating-point...
 	if ( !isMostlySafeCast( vdt, tdt ) ) {
-		throw new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', vdt, tdt ) );
+		throw new TypeError( format( '1rXEw', vdt, tdt ) );
 	}
 	// When performing a real-to-complex assignment, interpret the real-valued array as containing real components with implied imaginary components equal to zero and explicitly convert to a complex-valued array...
 	if ( isComplexDataType( tdt ) && isRealDataType( vdt ) ) {
diff --git a/lib/validate.js b/lib/validate.js
index 847d046..506c90d 100644
--- a/lib/validate.js
+++ b/lib/validate.js
@@ -24,7 +24,7 @@ var isObject = require( '@stdlib/assert-is-plain-object' );
 var hasOwnProp = require( '@stdlib/assert-has-own-property' );
 var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;
 var isMethodIn = require( '@stdlib/assert-is-method-in' );
-var format = require( '@stdlib/string-format' );
+var format = require( '@stdlib/error-tools-fmtprodmsg' );
 
 
 // MAIN //
@@ -51,12 +51,12 @@ var format = require( '@stdlib/string-format' );
 */
 function validate( opts, options ) {
 	if ( !isObject( options ) ) {
-		return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
+		return new TypeError( format( '1rX2V', options ) );
 	}
 	if ( hasOwnProp( options, 'strict' ) ) {
 		opts.strict = options.strict;
 		if ( !isBoolean( opts.strict ) ) {
-			return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', opts.strict ) );
+			return new TypeError( format( '1rX2o', 'strict', opts.strict ) );
 		}
 	}
 	if ( hasOwnProp( options, 'cache' ) ) {
diff --git a/lib/validator.js b/lib/validator.js
index 2d02051..a3d1784 100644
--- a/lib/validator.js
+++ b/lib/validator.js
@@ -32,7 +32,7 @@ var isSafeCast = require( '@stdlib/array-base-assert-is-safe-data-type-cast' );
 var minDataType = require( '@stdlib/array-min-dtype' );
 var minSignedIntegerDataType = require( '@stdlib/array-base-min-signed-integer-dtype' );
 var complexDataType = require( '@stdlib/complex-dtype' );
-var format = require( '@stdlib/string-format' );
+var format = require( '@stdlib/error-tools-fmtprodmsg' );
 
 
 // FUNCTIONS //
@@ -75,7 +75,7 @@ function validateBoolean( value, dtype ) {
 	if ( isBoolean( value ) ) {
 		return null;
 	}
-	return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );
+	return new TypeError( format( '1rXEw', typeof value, dtype ) );
 }
 
 /**
@@ -101,9 +101,9 @@ function validateRealFloating( value, dtype ) {
 		return null;
 	}
 	if ( isComplexLike( value ) ) {
-		return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', complexDataType( value ), dtype ) );
+		return new TypeError( format( '1rXEw', complexDataType( value ), dtype ) );
 	}
-	return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );
+	return new TypeError( format( '1rXEw', typeof value, dtype ) );
 }
 
 /**
@@ -128,7 +128,7 @@ function validateComplexFloating( value, dtype ) {
 	if ( isNumber( value ) || isComplexLike( value ) ) {
 		return null;
 	}
-	return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );
+	return new TypeError( format( '1rXEw', typeof value, dtype ) );
 }
 
 /**
@@ -151,18 +151,18 @@ function validateSignedInteger( value, dtype ) {
 	var vdt;
 	if ( isNumber( value ) ) {
 		if ( !isInteger( value ) ) {
-			return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', minDataType( value ), dtype ) );
+			return new TypeError( format( '1rXEw', minDataType( value ), dtype ) );
 		}
 		vdt = minSignedIntegerDataType( value );
 		if ( isSafeCast( vdt, dtype ) ) {
 			return null;
 		}
-		return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', vdt, dtype ) );
+		return new TypeError( format( '1rXEw', vdt, dtype ) );
 	}
 	if ( isComplexLike( value ) ) {
-		return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', complexDataType( value ), dtype ) );
+		return new TypeError( format( '1rXEw', complexDataType( value ), dtype ) );
 	}
-	return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );
+	return new TypeError( format( '1rXEw', typeof value, dtype ) );
 }
 
 /**
@@ -188,12 +188,12 @@ function validateUnsignedInteger( value, dtype ) {
 		if ( isSafeCast( vdt, dtype ) ) {
 			return null;
 		}
-		return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', vdt, dtype ) );
+		return new TypeError( format( '1rXEw', vdt, dtype ) );
 	}
 	if ( isComplexLike( value ) ) {
-		return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', complexDataType( value ), dtype ) );
+		return new TypeError( format( '1rXEw', complexDataType( value ), dtype ) );
 	}
-	return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );
+	return new TypeError( format( '1rXEw', typeof value, dtype ) );
 }
 
 
diff --git a/package.json b/package.json
index 3d0712f..5399610 100644
--- a/package.json
+++ b/package.json
@@ -81,7 +81,7 @@
     "@stdlib/string-base-replace": "^0.2.2",
     "@stdlib/string-base-starts-with": "^0.2.2",
     "@stdlib/string-base-trim": "^0.2.2",
-    "@stdlib/string-format": "^0.2.2",
+    "@stdlib/error-tools-fmtprodmsg": "^0.2.2",
     "@stdlib/types": "^0.4.3",
     "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
     "@stdlib/error-tools-fmtprodmsg": "^0.2.2"
