Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit71f6d2e

Browse files
committed
Transform error messages
1 parentd9b2669 commit71f6d2e

File tree

9 files changed

+28
-28
lines changed

9 files changed

+28
-28
lines changed

‎lib/factory.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var isArrayLike = require( '@stdlib/assert-is-array-like' );
2424
varProxy=require('@stdlib/proxy-ctor');
2525
vararraylike2object=require('@stdlib/array-base-arraylike2object');
2626
varassign=require('@stdlib/object-assign');
27-
varformat=require('@stdlib/string-format');
27+
varformat=require('@stdlib/error-tools-fmtprodmsg');
2828
varsetElementWrapper=require('./set_element_wrapper.js');
2929
vargetArrayWrapper=require('./get_array_wrapper.js');
3030
varhasProxySupport=require('./has_proxy_support.js');
@@ -125,7 +125,7 @@ function factory() {
125125
vardt;
126126
varo;
127127
if(!isArrayLike(x)){
128-
thrownewTypeError(format('invalid argument. First argument must be array-like. Value: `%s`.',x));
128+
thrownewTypeError(format('1rX38',x));
129129
}
130130
if(hasProxySupport){
131131
opts=assign({},OPTIONS);

‎lib/get_elements.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
vartake=require('@stdlib/array-take');
2424
varmskfilter=require('@stdlib/array-mskfilter');
2525
varmskreject=require('@stdlib/array-mskreject');
26-
varformat=require('@stdlib/string-format');
26+
varformat=require('@stdlib/error-tools-fmtprodmsg');
2727
varprop2array=require('./prop2array.js');
2828

2929

‎lib/prop2array.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MODULES //
2222

2323
vartrim=require('@stdlib/string-base-trim');
24-
varformat=require('@stdlib/string-format');
24+
varformat=require('@stdlib/error-tools-fmtprodmsg');
2525

2626

2727
// FUNCTIONS //

‎lib/prop2slice.js‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var trim = require( '@stdlib/string-base-trim' );
2424
varseq2slice=require('@stdlib/slice-base-seq2slice');
2525
varstr2slice=require('@stdlib/slice-base-str2slice');
2626
varstartsWith=require('@stdlib/string-base-starts-with');
27-
varformat=require('@stdlib/string-format');
27+
varformat=require('@stdlib/error-tools-fmtprodmsg');
2828
varRE_SUBSEQ=require('./re_subseq.js');
2929

3030

@@ -89,7 +89,7 @@ function isSubsequence( prop ) {
8989
functionparseSlice(raw,str){
9090
vars=str2slice(str);
9191
if(s===null){
92-
thrownewError(format('invalid operation. Unsupported slice operation. Value: `%s`.',raw));
92+
thrownewError(format('1rXEn',raw));
9393
}
9494
returns;
9595
}
@@ -114,15 +114,15 @@ function parseSubsequence( raw, str, max, strict ) {
114114
vars=seq2slice(str,max,true);
115115
if(s.code){
116116
if(s.code==='ERR_SLICE_INVALID_INCREMENT'){
117-
thrownewError(format('invalid operation. A subsequence increment must be a non-zero integer. Value: `%s`.',raw));
117+
thrownewError(format('1rXEq',raw));
118118
}
119119
if(s.code==='ERR_SLICE_INVALID_SUBSEQUENCE'){
120-
thrownewError(format('invalid operation. Unsupported slice operation. Value: `%s`.',raw));
120+
thrownewError(format('1rXEn',raw));
121121
}
122122
// NOTE: the following error check must come last due to fall-through when in non-strict mode...
123123
if(s.code==='ERR_SLICE_OUT_OF_BOUNDS'){
124124
if(strict){
125-
thrownewRangeError(format('invalid operation. Slice exceeds array bounds.'));
125+
thrownewRangeError(format('1rXFU'));
126126
}
127127
// Repeat parsing, this time allowing for out-of-bounds slices:
128128
s=seq2slice(str,max,false);

‎lib/resolve_index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MODULES //
2222

2323
varnormalizeIndex=require('@stdlib/ndarray-base-normalize-index');
24-
varformat=require('@stdlib/string-format');
24+
varformat=require('@stdlib/error-tools-fmtprodmsg');
2525

2626

2727
// MAIN //

‎lib/set_elements.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var put = require( '@stdlib/array-put' );
3030
varplace=require('@stdlib/array-place');
3131
varconvert=require('@stdlib/array-convert');
3232
varwhere=require('@stdlib/array-base-where').assign;
33-
varformat=require('@stdlib/string-format');
33+
varformat=require('@stdlib/error-tools-fmtprodmsg');
3434
varprop2array=require('./prop2array.js');
3535
varerrMessage=require('./error_message.js');
3636

@@ -106,7 +106,7 @@ function setElements( target, property, value, ctx ) {
106106
}
107107
// Safe casts are always allowed and allow same kind casts (i.e., downcasts) only when the target array data type is floating-point...
108108
if(!isMostlySafeCast(vdt,tdt)){
109-
thrownewTypeError(format('invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].',vdt,tdt));
109+
thrownewTypeError(format('1rXEw',vdt,tdt));
110110
}
111111
// 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...
112112
if(isComplexDataType(tdt)&&isRealDataType(vdt)){

‎lib/validate.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var isObject = require( '@stdlib/assert-is-plain-object' );
2424
varhasOwnProp=require('@stdlib/assert-has-own-property');
2525
varisBoolean=require('@stdlib/assert-is-boolean').isPrimitive;
2626
varisMethodIn=require('@stdlib/assert-is-method-in');
27-
varformat=require('@stdlib/string-format');
27+
varformat=require('@stdlib/error-tools-fmtprodmsg');
2828

2929

3030
// MAIN //
@@ -51,12 +51,12 @@ var format = require( '@stdlib/string-format' );
5151
*/
5252
functionvalidate(opts,options){
5353
if(!isObject(options)){
54-
returnnewTypeError(format('invalid argument. Options argument must be an object. Value: `%s`.',options));
54+
returnnewTypeError(format('1rX2V',options));
5555
}
5656
if(hasOwnProp(options,'strict')){
5757
opts.strict=options.strict;
5858
if(!isBoolean(opts.strict)){
59-
returnnewTypeError(format('invalid option. `%s` option must be a boolean. Option: `%s`.','strict',opts.strict));
59+
returnnewTypeError(format('1rX2o','strict',opts.strict));
6060
}
6161
}
6262
if(hasOwnProp(options,'cache')){

‎lib/validator.js‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var isSafeCast = require( '@stdlib/array-base-assert-is-safe-data-type-cast' );
3232
varminDataType=require('@stdlib/array-min-dtype');
3333
varminSignedIntegerDataType=require('@stdlib/array-base-min-signed-integer-dtype');
3434
varcomplexDataType=require('@stdlib/complex-dtype');
35-
varformat=require('@stdlib/string-format');
35+
varformat=require('@stdlib/error-tools-fmtprodmsg');
3636

3737

3838
// FUNCTIONS //
@@ -75,7 +75,7 @@ function validateBoolean( value, dtype ) {
7575
if(isBoolean(value)){
7676
returnnull;
7777
}
78-
returnnewTypeError(format('invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].',typeofvalue,dtype));
78+
returnnewTypeError(format('1rXEw',typeofvalue,dtype));
7979
}
8080

8181
/**
@@ -101,9 +101,9 @@ function validateRealFloating( value, dtype ) {
101101
returnnull;
102102
}
103103
if(isComplexLike(value)){
104-
returnnewTypeError(format('invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].',complexDataType(value),dtype));
104+
returnnewTypeError(format('1rXEw',complexDataType(value),dtype));
105105
}
106-
returnnewTypeError(format('invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].',typeofvalue,dtype));
106+
returnnewTypeError(format('1rXEw',typeofvalue,dtype));
107107
}
108108

109109
/**
@@ -128,7 +128,7 @@ function validateComplexFloating( value, dtype ) {
128128
if(isNumber(value)||isComplexLike(value)){
129129
returnnull;
130130
}
131-
returnnewTypeError(format('invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].',typeofvalue,dtype));
131+
returnnewTypeError(format('1rXEw',typeofvalue,dtype));
132132
}
133133

134134
/**
@@ -151,18 +151,18 @@ function validateSignedInteger( value, dtype ) {
151151
varvdt;
152152
if(isNumber(value)){
153153
if(!isInteger(value)){
154-
returnnewTypeError(format('invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].',minDataType(value),dtype));
154+
returnnewTypeError(format('1rXEw',minDataType(value),dtype));
155155
}
156156
vdt=minSignedIntegerDataType(value);
157157
if(isSafeCast(vdt,dtype)){
158158
returnnull;
159159
}
160-
returnnewTypeError(format('invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].',vdt,dtype));
160+
returnnewTypeError(format('1rXEw',vdt,dtype));
161161
}
162162
if(isComplexLike(value)){
163-
returnnewTypeError(format('invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].',complexDataType(value),dtype));
163+
returnnewTypeError(format('1rXEw',complexDataType(value),dtype));
164164
}
165-
returnnewTypeError(format('invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].',typeofvalue,dtype));
165+
returnnewTypeError(format('1rXEw',typeofvalue,dtype));
166166
}
167167

168168
/**
@@ -188,12 +188,12 @@ function validateUnsignedInteger( value, dtype ) {
188188
if(isSafeCast(vdt,dtype)){
189189
returnnull;
190190
}
191-
returnnewTypeError(format('invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].',vdt,dtype));
191+
returnnewTypeError(format('1rXEw',vdt,dtype));
192192
}
193193
if(isComplexLike(value)){
194-
returnnewTypeError(format('invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].',complexDataType(value),dtype));
194+
returnnewTypeError(format('1rXEw',complexDataType(value),dtype));
195195
}
196-
returnnewTypeError(format('invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].',typeofvalue,dtype));
196+
returnnewTypeError(format('1rXEw',typeofvalue,dtype));
197197
}
198198

199199

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"@stdlib/string-base-replace":"^0.2.2",
8282
"@stdlib/string-base-starts-with":"^0.2.2",
8383
"@stdlib/string-base-trim":"^0.2.2",
84-
"@stdlib/string-format":"^0.2.2",
84+
"@stdlib/error-tools-fmtprodmsg":"^0.2.2",
8585
"@stdlib/types":"^0.4.3",
8686
"@stdlib/utils-define-nonenumerable-read-only-property":"^0.2.2",
8787
"@stdlib/error-tools-fmtprodmsg":"^0.2.2"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp