From f28b73ad46b60c88f52294c747c05764c38e62f7 Mon Sep 17 00:00:00 2001 From: micnic Date: Thu, 19 Feb 2015 17:37:30 +0200 Subject: [PATCH] Consistent error messages in all modules This commit fixes some error messages that are not consistent with some general rules which most of error messages follow. --- lib/_http_outgoing.js | 18 +++++++++--------- lib/_stream_readable.js | 4 ++-- lib/_stream_transform.js | 8 ++++---- lib/_stream_writable.js | 4 ++-- lib/_tls_wrap.js | 2 +- lib/assert.js | 2 +- lib/buffer.js | 20 ++++++++++---------- lib/child_process.js | 8 ++++---- lib/crypto.js | 6 +++--- lib/dgram.js | 4 ++-- lib/dns.js | 14 +++++++------- lib/events.js | 8 ++++---- lib/fs.js | 12 ++++++------ lib/module.js | 8 ++++---- lib/net.js | 12 +++++++----- lib/path.js | 12 ++++++------ lib/readline.js | 6 +++--- lib/repl.js | 2 +- lib/smalloc.js | 10 +++++----- lib/timers.js | 5 +++-- lib/tty.js | 2 +- lib/url.js | 2 +- lib/zlib.js | 2 +- 23 files changed, 87 insertions(+), 84 deletions(-) diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 88590551c9defb..7a29fbdfbb1b58 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -325,11 +325,11 @@ function storeHeader(self, state, field, value) { OutgoingMessage.prototype.setHeader = function(name, value) { if (typeof name !== 'string') - throw new TypeError('`name` should be a string in setHeader(name, value).'); + throw new TypeError('"name" should be a string in setHeader(name, value)'); if (value === undefined) - throw new Error('`value` required in setHeader("' + name + '", value).'); + throw new Error('"value" is required in setHeader("' + name + '", value)'); if (this._header) - throw new Error('Can\'t set headers after they are sent.'); + throw new Error('Can\'t set headers after they are sent'); if (this._headers === null) this._headers = {}; @@ -345,7 +345,7 @@ OutgoingMessage.prototype.setHeader = function(name, value) { OutgoingMessage.prototype.getHeader = function(name) { if (arguments.length < 1) { - throw new Error('`name` is required for getHeader(name).'); + throw new Error('"name" is required for getHeader(name)'); } if (!this._headers) return; @@ -357,11 +357,11 @@ OutgoingMessage.prototype.getHeader = function(name) { OutgoingMessage.prototype.removeHeader = function(name) { if (arguments.length < 1) { - throw new Error('`name` is required for removeHeader(name).'); + throw new Error('"name" is required for removeHeader(name)'); } if (this._header) { - throw new Error('Can\'t remove headers after they are sent.'); + throw new Error('Can\'t remove headers after they are sent'); } var key = name.toLowerCase(); @@ -380,7 +380,7 @@ OutgoingMessage.prototype.removeHeader = function(name) { OutgoingMessage.prototype._renderHeaders = function() { if (this._header) { - throw new Error('Can\'t render headers after they are sent to the client.'); + throw new Error('Can\'t render headers after they are sent to the client'); } var headersMap = this._headers; @@ -424,7 +424,7 @@ OutgoingMessage.prototype.write = function(chunk, encoding, callback) { } if (typeof chunk !== 'string' && !(chunk instanceof Buffer)) { - throw new TypeError('first argument must be a string or Buffer'); + throw new TypeError('First argument must be a string or Buffer'); } @@ -511,7 +511,7 @@ OutgoingMessage.prototype.end = function(data, encoding, callback) { } if (data && typeof data !== 'string' && !(data instanceof Buffer)) { - throw new TypeError('first argument must be a string or Buffer'); + throw new TypeError('First argument must be a string or Buffer'); } if (this.finished) { diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 1de55597123d1b..8dc0e8bae7f9f8 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -441,7 +441,7 @@ function maybeReadMore_(stream, state) { // for virtual (non-string, non-buffer) streams, "length" is somewhat // arbitrary, and perhaps not very meaningful. Readable.prototype._read = function(n) { - this.emit('error', new Error('not implemented')); + this.emit('error', new Error('Not implemented')); }; Readable.prototype.pipe = function(dest, pipeOpts) { @@ -874,7 +874,7 @@ function endReadable(stream) { // If we get here before consuming all the bytes, then that is a // bug in node. Should never happen. if (state.length > 0) - throw new Error('endReadable called on non-empty stream'); + throw new Error('"endReadable" called on non-empty stream'); if (!state.endEmitted) { state.ended = true; diff --git a/lib/_stream_transform.js b/lib/_stream_transform.js index 8ff428e11ffed0..550bc86fb0ecfe 100644 --- a/lib/_stream_transform.js +++ b/lib/_stream_transform.js @@ -67,7 +67,7 @@ function afterTransform(stream, er, data) { var cb = ts.writecb; if (!cb) - return stream.emit('error', new Error('no writecb in Transform class')); + return stream.emit('error', new Error('No "writecb" in Transform class')); ts.writechunk = null; ts.writecb = null; @@ -139,7 +139,7 @@ Transform.prototype.push = function(chunk, encoding) { // an error, then that'll put the hurt on the whole operation. If you // never call cb(), then you'll never get another chunk. Transform.prototype._transform = function(chunk, encoding, cb) { - throw new Error('not implemented'); + throw new Error('Not implemented'); }; Transform.prototype._write = function(chunk, encoding, cb) { @@ -183,10 +183,10 @@ function done(stream, er) { var ts = stream._transformState; if (ws.length) - throw new Error('calling transform done when ws.length != 0'); + throw new Error('Calling transform done when ws.length != 0'); if (ts.transforming) - throw new Error('calling transform done when still transforming'); + throw new Error('Calling transform done when still transforming'); return stream.push(null); } diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index da65ddb90ae5ca..e6a385a824dbf9 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -155,7 +155,7 @@ Writable.prototype.pipe = function() { function writeAfterEnd(stream, cb) { - var er = new Error('write after end'); + var er = new Error('Write after end'); // TODO: defer error events consistently everywhere, not just the cb stream.emit('error', er); process.nextTick(cb, er); @@ -417,7 +417,7 @@ function clearBuffer(stream, state) { } Writable.prototype._write = function(chunk, encoding, cb) { - cb(new Error('not implemented')); + cb(new Error('Not implemented')); }; Writable.prototype._writev = null; diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 122c7042a4cf2f..365a8caea3ac02 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -671,7 +671,7 @@ function Server(/* [options], listener */) { var timeout = options.handshakeTimeout || (120 * 1000); if (typeof timeout !== 'number') { - throw new TypeError('handshakeTimeout must be a number'); + throw new TypeError('"handshakeTimeout" option must be a number'); } if (self.sessionTimeout) { diff --git a/lib/assert.js b/lib/assert.js index 4a01e5c7f0b356..30c91d27a9c3d2 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -280,7 +280,7 @@ function _throws(shouldThrow, block, expected, message) { var actual; if (typeof block !== 'function') { - throw new TypeError('block must be a function'); + throw new TypeError('"block" argument must be a function'); } if (typeof expected === 'string') { diff --git a/lib/buffer.js b/lib/buffer.js index 8f4e34d289fc27..5895de813ef823 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -404,7 +404,7 @@ Buffer.prototype.fill = function fill(val, start, end) { end = (end === undefined) ? this.length : end >> 0; if (start < 0 || end > this.length) - throw new RangeError('out of range index'); + throw new RangeError('Index out of range'); if (end <= start) return this; @@ -426,7 +426,7 @@ Buffer.prototype.fill = function fill(val, start, end) { Buffer.prototype.get = util.deprecate(function get(offset) { offset = ~~offset; if (offset < 0 || offset >= this.length) - throw new RangeError('index out of range'); + throw new RangeError('Index out of range'); return this[offset]; }, '.get() is deprecated. Access using array indexes instead.'); @@ -435,7 +435,7 @@ Buffer.prototype.get = util.deprecate(function get(offset) { Buffer.prototype.set = util.deprecate(function set(offset, v) { offset = ~~offset; if (offset < 0 || offset >= this.length) - throw new RangeError('index out of range'); + throw new RangeError('Index out of range'); return this[offset] = v; }, '.set() is deprecated. Set using array indexes instead.'); @@ -493,7 +493,7 @@ Buffer.prototype.write = function(string, offset, length, encoding) { length = remaining; if (string.length > 0 && (length < 0 || offset < 0)) - throw new RangeError('attempt to write outside buffer bounds'); + throw new RangeError('Attempt to write outside buffer bounds'); if (!encoding) encoding = 'utf8'; @@ -580,7 +580,7 @@ Buffer.prototype.slice = function(start, end) { function checkOffset(offset, ext, length) { if (offset + ext > length) - throw new RangeError('index out of range'); + throw new RangeError('Index out of range'); } @@ -788,11 +788,11 @@ Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { function checkInt(buffer, value, offset, ext, max, min) { if (!(buffer instanceof Buffer)) - throw new TypeError('buffer must be a Buffer instance'); + throw new TypeError('"buffer" argument must be a Buffer instance'); if (value > max || value < min) - throw new TypeError('value is out of bounds'); + throw new RangeError('"value" argument is out of bounds'); if (offset + ext > buffer.length) - throw new RangeError('index out of range'); + throw new RangeError('Index out of range'); } @@ -994,9 +994,9 @@ Buffer.prototype.writeInt32BE = function(value, offset, noAssert) { function checkFloat(buffer, value, offset, ext) { if (!(buffer instanceof Buffer)) - throw new TypeError('buffer must be a Buffer instance'); + throw new TypeError('"buffer" argument must be a Buffer instance'); if (offset + ext > buffer.length) - throw new RangeError('index out of range'); + throw new RangeError('Index out of range'); } diff --git a/lib/child_process.js b/lib/child_process.js index 99da7cfbde94dc..0ca4145895d6ba 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -363,7 +363,7 @@ function setupChannel(target, channel) { target.send = function(message, handle) { if (!this.connected) - this.emit('error', new Error('channel closed')); + this.emit('error', new Error('Channel closed')); else this._send(message, handle, false); }; @@ -372,7 +372,7 @@ function setupChannel(target, channel) { assert(this.connected || this._channel); if (message === undefined) - throw new TypeError('message cannot be undefined'); + throw new TypeError('"message" argument cannot be undefined'); // package messages with a handle object if (handle) { @@ -394,7 +394,7 @@ function setupChannel(target, channel) { } else if (handle instanceof UDP) { message.type = 'dgram.Native'; } else { - throw new TypeError("This handle type can't be sent"); + throw new TypeError('This handle type can\'t be sent'); } // Queue-up message and handle if we haven't received ACK yet. @@ -900,7 +900,7 @@ function normalizeSpawnArguments(file /*, args, options*/) { if (options === undefined) options = {}; else if (options === null || typeof options !== 'object') - throw new TypeError('options argument must be an object'); + throw new TypeError('"options" argument must be an object'); options = util._extend({}, options); args.unshift(file); diff --git a/lib/crypto.js b/lib/crypto.js index 10ff71e8547606..7b13b3e4e64ec7 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -515,7 +515,7 @@ DiffieHellman.prototype.setPrivateKey = function(key, encoding) { function ECDH(curve) { if (typeof curve !== 'string') - throw new TypeError('curve should be a string'); + throw new TypeError('"curve" argument should be a string'); this._handle = new binding.ECDH(curve); } @@ -634,10 +634,10 @@ Certificate.prototype.exportChallenge = function(object, encoding) { exports.setEngine = function setEngine(id, flags) { if (typeof id !== 'string') - throw new TypeError('id should be a string'); + throw new TypeError('"id" argument should be a string'); if (flags && typeof flags !== 'number') - throw new TypeError('flags should be a number, if present'); + throw new TypeError('"flags" argument should be a number, if present'); flags = flags >>> 0; // Use provided engine for everything by default diff --git a/lib/dgram.js b/lib/dgram.js index 7d2592819a8e87..0db1393bd385ab 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -425,7 +425,7 @@ Socket.prototype.addMembership = function(multicastAddress, this._healthCheck(); if (!multicastAddress) { - throw new Error('multicast address must be specified'); + throw new Error('Multicast address must be specified'); } var err = this._handle.addMembership(multicastAddress, interfaceAddress); @@ -440,7 +440,7 @@ Socket.prototype.dropMembership = function(multicastAddress, this._healthCheck(); if (!multicastAddress) { - throw new Error('multicast address must be specified'); + throw new Error('Multicast address must be specified'); } var err = this._handle.dropMembership(multicastAddress, interfaceAddress); diff --git a/lib/dns.js b/lib/dns.js index 9334800e4da5c4..21819f7bef73e4 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -126,7 +126,7 @@ exports.lookup = function lookup(hostname, options, callback) { hints !== exports.ADDRCONFIG && hints !== exports.V4MAPPED && hints !== (exports.ADDRCONFIG | exports.V4MAPPED)) { - throw new TypeError('invalid argument: hints must use valid flags'); + throw new TypeError('Invalid argument: hints must use valid flags'); } // FIXME(indutny): V4MAPPED on FreeBSD results in EAI_BADFLAGS, because @@ -138,7 +138,7 @@ exports.lookup = function lookup(hostname, options, callback) { } if (family !== 0 && family !== 4 && family !== 6) - throw new TypeError('invalid argument: family must be 4 or 6'); + throw new TypeError('Invalid argument: family must be 4 or 6'); callback = makeAsync(callback); @@ -189,10 +189,10 @@ function onlookupservice(err, host, service) { // lookupService(address, port, callback) exports.lookupService = function(host, port, callback) { if (arguments.length !== 3) - throw new Error('invalid arguments'); + throw new Error('Invalid arguments'); if (cares.isIP(host) === 0) - throw new TypeError('host needs to be a valid IP address'); + throw new TypeError('"host" argument must be a valid IP address'); callback = makeAsync(callback); @@ -223,9 +223,9 @@ function resolver(bindingName) { return function query(name, callback) { if (typeof name !== 'string') { - throw new Error('Name must be a string'); + throw new Error('"name" argument must be a string'); } else if (typeof callback !== 'function') { - throw new Error('Callback must be a function'); + throw new Error('"callback" argument must be a function'); } callback = makeAsync(callback); @@ -265,7 +265,7 @@ exports.resolve = function(hostname, type_, callback_) { resolver = exports.resolve4; callback = type_; } else { - throw new Error('Type must be a string'); + throw new Error('"type" argument must be a string'); } if (typeof resolver === 'function') { diff --git a/lib/events.js b/lib/events.js index 064f3838b38ac9..73b5c96256b4d5 100644 --- a/lib/events.js +++ b/lib/events.js @@ -42,7 +42,7 @@ EventEmitter.init = function() { // that to be increased. Set to zero for unlimited. EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { if (typeof n !== 'number' || n < 0 || isNaN(n)) - throw new TypeError('n must be a positive number'); + throw new TypeError('"n" argument must be a positive number'); this._maxListeners = n; return this; }; @@ -191,7 +191,7 @@ EventEmitter.prototype.addListener = function addListener(type, listener) { var existing; if (typeof listener !== 'function') - throw new TypeError('listener must be a function'); + throw new TypeError('"listener" argument must be a function'); events = this._events; if (!events) { @@ -245,7 +245,7 @@ EventEmitter.prototype.on = EventEmitter.prototype.addListener; EventEmitter.prototype.once = function once(type, listener) { if (typeof listener !== 'function') - throw new TypeError('listener must be a function'); + throw new TypeError('"listener" argument must be a function'); var fired = false; @@ -270,7 +270,7 @@ EventEmitter.prototype.removeListener = var list, events, position, i; if (typeof listener !== 'function') - throw new TypeError('listener must be a function'); + throw new TypeError('"listener" argument must be a function'); events = this._events; if (!events) diff --git a/lib/fs.js b/lib/fs.js index b6b62265403ee8..b3afd5ea25fac2 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -180,7 +180,7 @@ fs.access = function(path, mode, callback) { callback = mode; mode = fs.F_OK; } else if (typeof callback !== 'function') { - throw new TypeError('callback must be a function'); + throw new TypeError('"callback" argument must be a function'); } if (!nullCheck(path, callback)) @@ -1329,7 +1329,7 @@ fs.watchFile = function(filename) { } if (!listener) { - throw new Error('watchFile requires a listener function'); + throw new Error('"watchFile" requires a listener function'); } if (inStatWatchers(filename)) { @@ -1636,16 +1636,16 @@ function ReadStream(path, options) { if (this.start !== undefined) { if (typeof this.start !== 'number') { - throw new TypeError('start must be a Number'); + throw new TypeError('"start" option must be a number'); } if (this.end === undefined) { this.end = Infinity; } else if (typeof this.end !== 'number') { - throw new TypeError('end must be a Number'); + throw new TypeError('"end" option must be a number'); } if (this.start > this.end) { - throw new Error('start must be <= end'); + throw new Error('"start" must be <= "end"'); } this.pos = this.start; @@ -1893,7 +1893,7 @@ SyncWriteStream.prototype.write = function(data, arg1, arg2) { } else if (typeof arg1 === 'function') { cb = arg1; } else { - throw new Error('bad arg'); + throw new Error('Bad arguments'); } } assertEncoding(encoding); diff --git a/lib/module.js b/lib/module.js index 02f0ec700f150d..03ca8a60b457af 100644 --- a/lib/module.js +++ b/lib/module.js @@ -387,9 +387,9 @@ Module.prototype._compile = function(content, filename) { }; Object.defineProperty(require, 'paths', { get: function() { - throw new Error('require.paths is removed. Use ' + + throw new Error('"require.paths" is removed. Use ' + 'node_modules folders, or the NODE_PATH ' + - 'environment variable instead.'); + 'environment variable instead'); }}); require.main = process.mainModule; @@ -397,8 +397,8 @@ Module.prototype._compile = function(content, filename) { // Enable support to add extra extension types require.extensions = Module._extensions; require.registerExtension = function() { - throw new Error('require.registerExtension() removed. Use ' + - 'require.extensions instead.'); + throw new Error('"require.registerExtension()" is removed. Use ' + + '"require.extensions" instead'); }; require.cache = Module._cache; diff --git a/lib/net.js b/lib/net.js index 847e417e67f4ca..6e30c977c81ef2 100644 --- a/lib/net.js +++ b/lib/net.js @@ -599,7 +599,7 @@ Socket.prototype.__defineGetter__('localPort', function() { Socket.prototype.write = function(chunk, encoding, cb) { if (typeof chunk !== 'string' && !(chunk instanceof Buffer)) - throw new TypeError('invalid data'); + throw new TypeError('Invalid data'); return stream.Duplex.prototype.write.apply(this, arguments); }; @@ -892,17 +892,19 @@ Socket.prototype.connect = function(options, cb) { }; if (localAddress && !exports.isIP(localAddress)) - throw new TypeError('localAddress must be a valid IP: ' + localAddress); + throw new TypeError('"localAddress" argument must be a valid IP: ' + + localAddress); if (localPort && typeof localPort !== 'number') - throw new TypeError('localPort should be a number: ' + localPort); + throw new TypeError('"localPort" argument should be a number: ' + + localPort); port = options.port; if (typeof port !== 'undefined') { if (typeof port !== 'number' && typeof port !== 'string') - throw new TypeError('port should be a number or string: ' + port); + throw new TypeError('"port" should be a number or string: ' + port); if (!isLegalPort(port)) - throw new RangeError('port should be >= 0 and < 65536: ' + port); + throw new RangeError('"port" should be >= 0 and < 65536: ' + port); } port |= 0; diff --git a/lib/path.js b/lib/path.js index b7e28b22250791..77d1948e23d94f 100644 --- a/lib/path.js +++ b/lib/path.js @@ -341,7 +341,7 @@ win32.extname = function(path) { win32.format = function(pathObject) { if (pathObject === null || typeof pathObject !== 'object') { throw new TypeError( - "Parameter 'pathObject' must be an object, not " + typeof pathObject + 'Parameter "pathObject" must be an object, not ' + typeof pathObject ); } @@ -349,7 +349,7 @@ win32.format = function(pathObject) { if (typeof root !== 'string') { throw new TypeError( - "'pathObject.root' must be a string or undefined, not " + + '"pathObject.root" must be a string or undefined, not ' + typeof pathObject.root ); } @@ -373,7 +373,7 @@ win32.parse = function(pathString) { var allParts = win32SplitPath(pathString); if (!allParts || allParts.length !== 4) { - throw new TypeError("Invalid path '" + pathString + "'"); + throw new TypeError('Invalid path "' + pathString + '"'); } return { root: allParts[0], @@ -570,7 +570,7 @@ posix.extname = function(path) { posix.format = function(pathObject) { if (pathObject === null || typeof pathObject !== 'object') { throw new TypeError( - "Parameter 'pathObject' must be an object, not " + typeof pathObject + 'Parameter "pathObject" must be an object, not ' + typeof pathObject ); } @@ -578,7 +578,7 @@ posix.format = function(pathObject) { if (typeof root !== 'string') { throw new TypeError( - "'pathObject.root' must be a string or undefined, not " + + '"pathObject.root" must be a string or undefined, not ' + typeof pathObject.root ); } @@ -594,7 +594,7 @@ posix.parse = function(pathString) { var allParts = posixSplitPath(pathString); if (!allParts || allParts.length !== 4) { - throw new TypeError("Invalid path '" + pathString + "'"); + throw new TypeError('Invalid path "' + pathString + '"'); } allParts[1] = allParts[1] || ''; allParts[2] = allParts[2] || ''; diff --git a/lib/readline.js b/lib/readline.js index a6845010dae661..c6ba0fe577bc25 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -47,7 +47,7 @@ function Interface(input, output, completer, terminal) { completer = completer || function() { return []; }; if (typeof completer !== 'function') { - throw new TypeError('Argument \'completer\' must be a function'); + throw new TypeError('"completer" argument must be a function'); } // backwards compat; check the isTTY prop of the output stream @@ -201,7 +201,7 @@ Interface.prototype._onLine = function(line) { Interface.prototype._writeToOutput = function _writeToOutput(stringToWrite) { if (typeof stringToWrite !== 'string') - throw new TypeError('stringToWrite must be a string'); + throw new TypeError('"stringToWrite" argument must be a string'); if (this.output !== null && this.output !== undefined) this.output.write(stringToWrite); @@ -1174,7 +1174,7 @@ function cursorTo(stream, x, y) { return; if (typeof x !== 'number') - throw new Error("Can't set cursor row without also setting it's column"); + throw new Error('Can\'t set cursor row without also setting it\'s column'); if (typeof y !== 'number') { stream.write('\x1b[' + (x + 1) + 'G'); diff --git a/lib/repl.js b/lib/repl.js index 036b561f9c2a94..7848e5678b9b03 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -712,7 +712,7 @@ REPLServer.prototype.defineCommand = function(keyword, cmd) { if (typeof cmd === 'function') { cmd = {action: cmd}; } else if (typeof cmd.action !== 'function') { - throw new Error('bad argument, action must be a function'); + throw new Error('Bad argument, "action" option must be a function'); } this.commands[keyword] = cmd; }; diff --git a/lib/smalloc.js b/lib/smalloc.js index f181cb60cf2d7c..47b17ef6c12e85 100644 --- a/lib/smalloc.js +++ b/lib/smalloc.js @@ -33,7 +33,7 @@ function alloc(n, obj, type) { type = obj >>> 0; obj = {}; } else if (util.isPrimitive(obj)) { - throw new TypeError('obj must be an Object'); + throw new TypeError('"obj" argument must be an object'); } if (Array.isArray(obj)) @@ -57,13 +57,13 @@ function alloc(n, obj, type) { function dispose(obj) { if (util.isPrimitive(obj)) - throw new TypeError('obj must be an Object'); + throw new TypeError('"obj" argument must be an object'); if (obj instanceof Buffer) - throw new TypeError('obj cannot be a Buffer'); + throw new TypeError('"obj" argument cannot be a Buffer'); if (smalloc.isTypedArray(obj)) - throw new TypeError('obj cannot be a typed array'); + throw new TypeError('"obj" argument cannot be a typed array'); if (!smalloc.hasExternalData(obj)) - throw new TypeError('obj has no external array data'); + throw new TypeError('"obj" argument has no external array data'); smalloc.dispose(obj); } diff --git a/lib/timers.js b/lib/timers.js index 27c4b0717653ca..23a9117969d98a 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -132,11 +132,12 @@ const unenroll = exports.unenroll = function(item) { // Does not start the time, just sets up the members needed. exports.enroll = function(item, msecs) { if (typeof msecs !== 'number') { - throw new TypeError('msecs must be a number'); + throw new TypeError('"msecs" argument must be a number'); } if (msecs < 0 || !isFinite(msecs)) { - throw new RangeError('msecs must be a non-negative finite number'); + throw new RangeError('"msecs" argument must be ' + + 'a non-negative finite number'); } // if this item was already in a list somewhere diff --git a/lib/tty.js b/lib/tty.js index 1241d52535cfeb..ed0e58d1f6efc5 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -16,7 +16,7 @@ exports.isatty = function(fd) { // backwards-compat exports.setRawMode = util.deprecate(function(flag) { if (!process.stdin.isTTY) { - throw new Error('can\'t set raw mode on non-tty'); + throw new Error('Can\'t set raw mode on non-tty'); } process.stdin.setRawMode(flag); }, 'tty.setRawMode: Use `process.stdin.setRawMode()` instead.'); diff --git a/lib/url.js b/lib/url.js index 1683f905037c52..767e17f9d41f99 100644 --- a/lib/url.js +++ b/lib/url.js @@ -87,7 +87,7 @@ function urlParse(url, parseQueryString, slashesDenoteHost) { Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) { if (typeof url !== 'string') { - throw new TypeError("Parameter 'url' must be a string, not " + typeof url); + throw new TypeError('Parameter "url" must be a string, not ' + typeof url); } // Copy chrome, IE, opera backslash-handling behavior. diff --git a/lib/zlib.js b/lib/zlib.js index 4dd8b30b28a768..c0a8a9cea26727 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -469,7 +469,7 @@ Zlib.prototype._transform = function(chunk, encoding, cb) { var last = ending && (!chunk || ws.length === chunk.length); if (chunk !== null && !(chunk instanceof Buffer)) - return cb(new Error('invalid input')); + return cb(new Error('Invalid input')); if (this._closed) return cb(new Error('zlib binding closed'));