diff options
author | Michaël Zasso <targos@protonmail.com> | 2018-02-27 14:55:32 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2018-03-05 19:51:30 +0100 |
commit | 1e8d110e640c658e4f6ed7540db62d063269ba6c (patch) | |
tree | afe2636b1b190fee00006beaa484fa77d5949770 /lib/string_decoder.js | |
parent | 023f49c5a938ef631260b76876155eaf957084be (diff) | |
download | android-node-v8-1e8d110e640c658e4f6ed7540db62d063269ba6c.tar.gz android-node-v8-1e8d110e640c658e4f6ed7540db62d063269ba6c.tar.bz2 android-node-v8-1e8d110e640c658e4f6ed7540db62d063269ba6c.zip |
lib: port errors to new system
This is a first batch of updates that touches non-underscored modules in
lib.
PR-URL: https://github.com/nodejs/node/pull/19034
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'lib/string_decoder.js')
-rw-r--r-- | lib/string_decoder.js | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/string_decoder.js b/lib/string_decoder.js index 18097be0e6..a2b7cf7de2 100644 --- a/lib/string_decoder.js +++ b/lib/string_decoder.js @@ -34,7 +34,10 @@ const { encodings } = internalBinding('string_decoder'); const internalUtil = require('internal/util'); -const errors = require('internal/errors'); +const { + ERR_INVALID_ARG_TYPE, + ERR_UNKNOWN_ENCODING +} = require('internal/errors').codes; const isEncoding = Buffer[internalUtil.kIsEncodingSymbol]; const kNativeDecoder = Symbol('kNativeDecoder'); @@ -45,7 +48,7 @@ function normalizeEncoding(enc) { const nenc = internalUtil.normalizeEncoding(enc); if (nenc === undefined) { if (Buffer.isEncoding === isEncoding || !Buffer.isEncoding(enc)) - throw new errors.TypeError('ERR_UNKNOWN_ENCODING', enc); + throw new ERR_UNKNOWN_ENCODING(enc); return enc; } return nenc; @@ -68,8 +71,8 @@ StringDecoder.prototype.write = function write(buf) { if (typeof buf === 'string') return buf; if (!ArrayBuffer.isView(buf)) - throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'buf', - ['Buffer', 'Uint8Array', 'ArrayBufferView']); + throw new ERR_INVALID_ARG_TYPE('buf', + ['Buffer', 'Uint8Array', 'ArrayBufferView']); return decode(this[kNativeDecoder], buf); }; |