Skip to content

Commit 77a2712

Browse files
committed
Transform error messages
1 parent 19949b4 commit 77a2712

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

lib/factory.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MODULES //
2222

2323
var isObject = require( '@stdlib/assert-is-plain-object' );
24-
var format = require( '@stdlib/string-format' );
24+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
2525
var assign = require( '@stdlib/object-assign' );
2626
var ArrayStream = require( './main.js' );
2727

@@ -70,7 +70,7 @@ function factory( options ) {
7070
var opts;
7171
if ( arguments.length ) {
7272
if ( !isObject( options ) ) {
73-
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
73+
throw new TypeError( format( '1M92V', options ) );
7474
}
7575
opts = assign( {}, options );
7676
} else {

lib/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var Readable = require( 'readable-stream' ).Readable;
2424
var isCollection = require( '@stdlib/assert-is-collection' );
2525
var isError = require( '@stdlib/assert-is-error' );
2626
var isBuffer = require( '@stdlib/assert-is-buffer' );
27-
var format = require( '@stdlib/string-format' );
27+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
2828
var assign = require( '@stdlib/object-assign' );
2929
var inherit = require( '@stdlib/utils-inherit' );
3030
var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );
@@ -81,7 +81,7 @@ function read() {
8181
v = Buffer.concat( [ string2buffer( this._sep ), v ] );
8282
}
8383
} else {
84-
err = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );
84+
err = new Error( format( '1M9A9', v ) );
8585
}
8686
}
8787
if ( err ) {
@@ -181,7 +181,7 @@ function ArrayStream( src, options ) {
181181
return new ArrayStream( src );
182182
}
183183
if ( !isCollection( src ) ) {
184-
throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );
184+
throw new TypeError( format( '1M92O', src ) );
185185
}
186186
opts = assign( {}, DEFAULTS );
187187
if ( arguments.length > 1 ) {

lib/object_mode.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MODULES //
2222

2323
var isObject = require( '@stdlib/assert-is-plain-object' );
24-
var format = require( '@stdlib/string-format' );
24+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
2525
var assign = require( '@stdlib/object-assign' );
2626
var ArrayStream = require( './main.js' );
2727

@@ -65,7 +65,7 @@ function objectMode( src, options ) {
6565
if ( arguments.length > 1 ) {
6666
opts = options;
6767
if ( !isObject( opts ) ) {
68-
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );
68+
throw new TypeError( format( '1M92V', opts ) );
6969
}
7070
opts = assign( {}, options );
7171
} else {

lib/validate.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;
2626
var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;
2727
var isString = require( '@stdlib/assert-is-string' ).isPrimitive;
2828
var isFunction = require( '@stdlib/assert-is-function' );
29-
var format = require( '@stdlib/string-format' );
29+
var format = require( '@stdlib/error-tools-fmtprodmsg' );
3030

3131

3232
// MAIN //
@@ -57,42 +57,42 @@ var format = require( '@stdlib/string-format' );
5757
*/
5858
function validate( opts, options ) {
5959
if ( !isObject( options ) ) {
60-
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
60+
return new TypeError( format( '1M92V', options ) );
6161
}
6262
if ( hasOwnProp( options, 'sep' ) ) {
6363
opts.sep = options.sep;
6464
if ( !isString( opts.sep ) ) {
65-
return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );
65+
return new TypeError( format( '1M92W', 'sep', opts.sep ) );
6666
}
6767
}
6868
if ( hasOwnProp( options, 'objectMode' ) ) {
6969
opts.objectMode = options.objectMode;
7070
if ( !isBoolean( opts.objectMode ) ) {
71-
return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );
71+
return new TypeError( format( '1M92o', 'objectMode', opts.objectMode ) );
7272
}
7373
}
7474
if ( hasOwnProp( options, 'encoding' ) ) {
7575
opts.encoding = options.encoding;
7676
if ( !isString( opts.encoding ) && opts.encoding !== null ) {
77-
return new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );
77+
return new TypeError( format( '1M97n', 'encoding', opts.encoding ) );
7878
}
7979
}
8080
if ( hasOwnProp( options, 'highWaterMark' ) ) {
8181
opts.highWaterMark = options.highWaterMark;
8282
if ( !isNonNegative( opts.highWaterMark ) ) {
83-
return new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );
83+
return new TypeError( format( '1M94k', 'highWaterMark', opts.highWaterMark ) );
8484
}
8585
}
8686
if ( hasOwnProp( options, 'serialize' ) ) {
8787
opts.serialize = options.serialize;
8888
if ( !isFunction( opts.serialize ) ) {
89-
return new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );
89+
return new TypeError( format( '1M96p', 'serialize', opts.serialize ) );
9090
}
9191
}
9292
if ( hasOwnProp( options, 'dir' ) ) {
9393
opts.dir = options.dir;
9494
if ( opts.dir !== 1 && opts.dir !== -1 ) {
95-
return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );
95+
return new TypeError( format( '1M92v', 'dir', opts.dir ) );
9696
}
9797
}
9898
return null;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"@stdlib/buffer-ctor": "^0.2.2",
5050
"@stdlib/buffer-from-string": "^0.2.2",
5151
"@stdlib/object-assign": "^0.2.2",
52-
"@stdlib/string-format": "^0.2.2",
52+
"@stdlib/error-tools-fmtprodmsg": "^0.2.2",
5353
"@stdlib/types": "^0.4.3",
5454
"@stdlib/utils-define-nonenumerable-property": "^0.2.2",
5555
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",

0 commit comments

Comments
 (0)