summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/_http_client.js4
-rw-r--r--lib/_http_outgoing.js18
-rw-r--r--lib/_stream_readable.js2
-rw-r--r--lib/_stream_transform.js6
-rw-r--r--lib/_stream_writable.js2
-rw-r--r--lib/_tls_legacy.js4
-rw-r--r--lib/_tls_wrap.js6
-rw-r--r--lib/assert.js2
-rw-r--r--lib/buffer.js30
-rw-r--r--lib/child_process.js6
-rw-r--r--lib/crypto.js8
-rw-r--r--lib/dgram.js8
-rw-r--r--lib/dns.js18
-rw-r--r--lib/events.js10
-rw-r--r--lib/fs.js24
-rw-r--r--lib/internal/child_process.js4
-rw-r--r--lib/net.js19
-rw-r--r--lib/path.js10
-rw-r--r--lib/readline.js8
-rw-r--r--lib/repl.js2
-rw-r--r--lib/timers.js5
-rw-r--r--lib/tty.js2
-rw-r--r--lib/url.js4
-rw-r--r--lib/util.js12
-rw-r--r--lib/zlib.js2
25 files changed, 110 insertions, 106 deletions
diff --git a/lib/_http_client.js b/lib/_http_client.js
index 02d6e7ed37..912fbd4f39 100644
--- a/lib/_http_client.js
+++ b/lib/_http_client.js
@@ -51,10 +51,10 @@ function ClientRequest(options, cb) {
// well, and b) possibly too restrictive for real-world usage. That's
// why it only scans for spaces because those are guaranteed to create
// an invalid request.
- throw new TypeError('Request path contains unescaped characters.');
+ throw new TypeError('Request path contains unescaped characters');
} else if (protocol !== expectedProtocol) {
throw new Error('Protocol "' + protocol + '" not supported. ' +
- 'Expected "' + expectedProtocol + '".');
+ 'Expected "' + expectedProtocol + '"');
}
const defaultPort = options.defaultPort ||
diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js
index e3a258b1cd..99fa8ff723 100644
--- a/lib/_http_outgoing.js
+++ b/lib/_http_outgoing.js
@@ -337,11 +337,11 @@ OutgoingMessage.prototype.setHeader = function(name, value) {
throw new TypeError(
'Header name must be a valid HTTP Token ["' + name + '"]');
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" 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 = {};
@@ -357,7 +357,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" argument is required for getHeader(name)');
}
if (!this._headers) return;
@@ -369,11 +369,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" argument 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();
@@ -392,7 +392,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;
@@ -436,7 +436,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');
}
@@ -533,7 +533,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 ab47830767..0316a05571 100644
--- a/lib/_stream_readable.js
+++ b/lib/_stream_readable.js
@@ -889,7 +889,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 8ff428e11f..1378c0c676 100644
--- a/lib/_stream_transform.js
+++ b/lib/_stream_transform.js
@@ -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 9c7e263016..73f4d9fb3e 100644
--- a/lib/_stream_writable.js
+++ b/lib/_stream_writable.js
@@ -151,7 +151,7 @@ function Writable(options) {
// Otherwise people can pipe Writable streams, which is just wrong.
Writable.prototype.pipe = function() {
- this.emit('error', new Error('Cannot pipe. Not readable.'));
+ this.emit('error', new Error('Cannot pipe, not readable'));
};
diff --git a/lib/_tls_legacy.js b/lib/_tls_legacy.js
index 8c079e341b..52621c2a60 100644
--- a/lib/_tls_legacy.js
+++ b/lib/_tls_legacy.js
@@ -13,7 +13,7 @@ var Connection = null;
try {
Connection = process.binding('crypto').Connection;
} catch (e) {
- throw new Error('node.js not compiled with openssl crypto support.');
+ throw new Error('Node.js is not compiled with openssl crypto support');
}
function SlabBuffer() {
@@ -590,7 +590,7 @@ function onhandshakestart() {
// state machine and OpenSSL is not re-entrant. We cannot allow the user's
// callback to destroy the connection right now, it would crash and burn.
setImmediate(function() {
- var err = new Error('TLS session renegotiation attack detected.');
+ var err = new Error('TLS session renegotiation attack detected');
if (self.cleartext) self.cleartext.emit('error', err);
});
}
diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js
index 887db012e7..e79f63f405 100644
--- a/lib/_tls_wrap.js
+++ b/lib/_tls_wrap.js
@@ -37,7 +37,7 @@ function onhandshakestart() {
// state machine and OpenSSL is not re-entrant. We cannot allow the user's
// callback to destroy the connection right now, it would crash and burn.
setImmediate(function() {
- var err = new Error('TLS session renegotiation attack detected.');
+ var err = new Error('TLS session renegotiation attack detected');
self._emitTLSError(err);
});
}
@@ -756,7 +756,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) {
@@ -902,7 +902,7 @@ Server.prototype.setOptions = function(options) {
// SNI Contexts High-Level API
Server.prototype.addContext = function(servername, context) {
if (!servername) {
- throw new Error('Servername is required parameter for Server.addContext');
+ throw new Error('"servername" is required parameter for Server.addContext');
}
var re = new RegExp('^' +
diff --git a/lib/assert.js b/lib/assert.js
index 6b99098c5f..f8e4920cf3 100644
--- a/lib/assert.js
+++ b/lib/assert.js
@@ -285,7 +285,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 5355325320..dec02ed8e7 100644
--- a/lib/buffer.js
+++ b/lib/buffer.js
@@ -136,7 +136,7 @@ function fromObject(obj) {
}
if (obj == null) {
- throw new TypeError('must start with number, buffer, array or string');
+ throw new TypeError('Must start with number, buffer, array or string');
}
if (obj instanceof ArrayBuffer) {
@@ -164,7 +164,7 @@ function fromObject(obj) {
return b;
}
- throw new TypeError('must start with number, buffer, array or string');
+ throw new TypeError('Must start with number, buffer, array or string');
}
@@ -217,7 +217,7 @@ Buffer.isEncoding = function(encoding) {
Buffer.concat = function(list, length) {
if (!Array.isArray(list))
- throw new TypeError('list argument must be an Array of Buffers.');
+ throw new TypeError('"list" argument must be an Array of Buffers');
if (list.length === 0)
return new Buffer(0);
@@ -375,7 +375,7 @@ Buffer.prototype.toString = function() {
var result = slowToString.apply(this, arguments);
}
if (result === undefined)
- throw new Error('toString failed');
+ throw new Error('"toString()" failed');
return result;
};
@@ -462,7 +462,7 @@ Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
return binding.indexOfNumber(this, val, byteOffset);
}
- throw new TypeError('val must be string, number or Buffer');
+ throw new TypeError('"val" argument must be string, number or Buffer');
};
@@ -471,7 +471,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('Out of range index');
if (end <= start)
return this;
@@ -493,7 +493,7 @@ Buffer.prototype.fill = function fill(val, start, end) {
Buffer.prototype.get = internalUtil.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];
}, 'Buffer.get is deprecated. Use array indexes instead.');
@@ -502,7 +502,7 @@ Buffer.prototype.get = internalUtil.deprecate(function get(offset) {
Buffer.prototype.set = internalUtil.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;
}, 'Buffer.set is deprecated. Use array indexes instead.');
@@ -552,7 +552,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';
@@ -612,7 +612,7 @@ Buffer.prototype.slice = function slice(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');
}
@@ -820,11 +820,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 TypeError('"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');
}
@@ -1030,9 +1030,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 151fb51fc8..5abba8a534 100644
--- a/lib/child_process.js
+++ b/lib/child_process.js
@@ -251,7 +251,7 @@ exports.execFile = function(file /*, args, options, callback*/) {
stdoutLen += chunk.length;
if (stdoutLen > options.maxBuffer) {
- ex = new Error('stdout maxBuffer exceeded.');
+ ex = new Error('stdout maxBuffer exceeded');
kill();
} else {
if (!encoding)
@@ -265,7 +265,7 @@ exports.execFile = function(file /*, args, options, callback*/) {
stderrLen += chunk.length;
if (stderrLen > options.maxBuffer) {
- ex = new Error('stderr maxBuffer exceeded.');
+ ex = new Error('stderr maxBuffer exceeded');
kill();
} else {
if (!encoding)
@@ -316,7 +316,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 b32d9aff90..bed7d7764e 100644
--- a/lib/crypto.js
+++ b/lib/crypto.js
@@ -12,7 +12,7 @@ try {
var getHashes = binding.getHashes;
var getCurves = binding.getCurves;
} catch (e) {
- throw new Error('node.js not compiled with openssl crypto support.');
+ throw new Error('Node.js is not compiled with openssl crypto support');
}
const Buffer = require('buffer').Buffer;
@@ -486,7 +486,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);
}
@@ -604,10 +604,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 eaf84272d1..e172e41324 100644
--- a/lib/dgram.js
+++ b/lib/dgram.js
@@ -54,7 +54,7 @@ function newHandle(type) {
}
if (type == 'unix_dgram')
- throw new Error('unix_dgram sockets are not supported any more.');
+ throw new Error('"unix_dgram" type sockets are not supported any more');
throw new Error('Bad socket type specified. Valid types are: udp4, udp6');
}
@@ -233,7 +233,7 @@ Socket.prototype.sendto = function(buffer,
address,
callback) {
if (typeof offset !== 'number' || typeof length !== 'number')
- throw new Error('send takes offset and length as args 2 and 3');
+ throw new Error('Send takes "offset" and "length" as args 2 and 3');
if (typeof address !== 'string')
throw new Error(this.type + ' sockets must send to port, address');
@@ -254,7 +254,7 @@ Socket.prototype.send = function(buffer,
buffer = new Buffer(buffer);
if (!(buffer instanceof Buffer))
- throw new TypeError('First argument must be a buffer or string.');
+ throw new TypeError('First argument must be a buffer or string');
offset = offset | 0;
if (offset < 0)
@@ -262,7 +262,7 @@ Socket.prototype.send = function(buffer,
if ((length == 0 && offset > buffer.length) ||
(length > 0 && offset >= buffer.length))
- throw new RangeError('Offset into buffer too large');
+ throw new RangeError('Offset into buffer is too large');
// Sending a zero-length datagram is kind of pointless but it _is_
// allowed, hence check that length >= 0 rather than > 0.
diff --git a/lib/dns.js b/lib/dns.js
index 8bd61caee9..bdcd14a5c6 100644
--- a/lib/dns.js
+++ b/lib/dns.js
@@ -110,13 +110,13 @@ exports.lookup = function lookup(hostname, options, callback) {
// Parse arguments
if (hostname && typeof hostname !== 'string') {
- throw new TypeError('invalid arguments: ' +
+ throw new TypeError('Invalid arguments: ' +
'hostname must be a string or falsey');
} else if (typeof options === 'function') {
callback = options;
family = 0;
} else if (typeof callback !== 'function') {
- throw new TypeError('invalid arguments: callback must be passed');
+ throw new TypeError('Invalid arguments: callback must be passed');
} else if (options !== null && typeof options === 'object') {
hints = options.hints >>> 0;
family = options.family >>> 0;
@@ -126,14 +126,14 @@ 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');
}
} else {
family = options >>> 0;
}
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);
@@ -184,10 +184,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 needs to be a valid IP address');
callback = makeAsync(callback);
@@ -218,9 +218,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);
@@ -259,7 +259,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 ea3f2831eb..589dc4e79e 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;
};
@@ -132,7 +132,7 @@ EventEmitter.prototype.emit = function emit(type) {
er = arguments[1];
if (domain) {
if (!er)
- er = new Error('Uncaught, unspecified "error" event.');
+ er = new Error('Uncaught, unspecified "error" event');
er.domainEmitter = this;
er.domain = domain;
er.domainThrown = false;
@@ -194,7 +194,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) {
@@ -248,7 +248,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;
@@ -273,7 +273,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 22e00c7030..a009ecae02 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -75,7 +75,7 @@ function makeCallback(cb) {
}
if (typeof cb !== 'function') {
- throw new TypeError('callback must be a function');
+ throw new TypeError('"callback" argument must be a function');
}
return function() {
@@ -91,7 +91,7 @@ function assertEncoding(encoding) {
function nullCheck(path, callback) {
if (('' + path).indexOf('\u0000') !== -1) {
- var er = new Error('Path must be a string without null bytes.');
+ var er = new Error('Path must be a string without null bytes');
er.code = 'ENOENT';
if (typeof callback !== 'function')
throw er;
@@ -184,7 +184,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))
@@ -1410,7 +1410,7 @@ fs.watchFile = function(filename, options, listener) {
}
if (typeof listener !== 'function') {
- throw new Error('watchFile requires a listener function');
+ throw new Error('"watchFile()" requires a listener function');
}
stat = statWatchers.get(filename);
@@ -1703,7 +1703,7 @@ function ReadStream(path, options) {
else if (typeof options === 'string')
options = { encoding: options };
else if (options === null || typeof options !== 'object')
- throw new TypeError('options must be a string or an object');
+ throw new TypeError('"options" argument must be a string or an object');
// a little bit bigger buffer and water marks by default
options = Object.create(options);
@@ -1724,16 +1724,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" option must be <= "end" option');
}
this.pos = this.start;
@@ -1874,7 +1874,7 @@ function WriteStream(path, options) {
else if (typeof options === 'string')
options = { encoding: options };
else if (options === null || typeof options !== 'object')
- throw new TypeError('options must be a string or an object');
+ throw new TypeError('"options" argument must be a string or an object');
options = Object.create(options);
@@ -1891,10 +1891,10 @@ function WriteStream(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.start < 0) {
- throw new Error('start must be >= zero');
+ throw new Error('"start" must be >= zero');
}
this.pos = this.start;
@@ -2036,7 +2036,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/internal/child_process.js b/lib/internal/child_process.js
index e93e1ae2e6..6f396fac6c 100644
--- a/lib/internal/child_process.js
+++ b/lib/internal/child_process.js
@@ -519,7 +519,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) {
@@ -541,7 +541,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.
diff --git a/lib/net.js b/lib/net.js
index a7a8eb1fcc..d11fef84c2 100644
--- a/lib/net.js
+++ b/lib/net.js
@@ -614,7 +614,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);
};
@@ -637,7 +637,7 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) {
this._unrefTimer();
if (!this._handle) {
- this._destroy(new Error('This socket is closed.'), cb);
+ this._destroy(new Error('This socket is closed'), cb);
return false;
}
@@ -915,16 +915,18 @@ function lookupAndConnect(self, options) {
var localPort = options.localPort;
if (localAddress && !exports.isIP(localAddress))
- throw new TypeError('localAddress must be a valid IP: ' + localAddress);
+ throw new TypeError('"localAddress" option must be a valid IP: ' +
+ localAddress);
if (localPort && typeof localPort !== 'number')
- throw new TypeError('localPort should be a number: ' + localPort);
+ throw new TypeError('"localPort" option should be a number: ' + localPort);
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" option should be a number or string: ' +
+ port);
if (!isLegalPort(port))
- throw new RangeError('port should be >= 0 and < 65536: ' + port);
+ throw new RangeError('"port" option should be >= 0 and < 65536: ' + port);
}
port |= 0;
@@ -940,7 +942,7 @@ function lookupAndConnect(self, options) {
}
if (options.lookup && typeof options.lookup !== 'function')
- throw new TypeError('options.lookup should be a function.');
+ throw new TypeError('"lookup" option should be a function');
var dnsopts = {
family: options.family,
@@ -1342,7 +1344,8 @@ Server.prototype.listen = function() {
// Undefined is interpreted as zero (random port) for consistency
// with net.connect().
if (typeof h.port !== 'undefined' && !isLegalPort(h.port))
- throw new RangeError('port should be >= 0 and < 65536: ' + h.port);
+ throw new RangeError('"port" option should be >= 0 and < 65536: ' +
+ h.port);
if (h.host)
listenAfterLookup(h.port | 0, h.host, backlog, h.exclusive);
else
diff --git a/lib/path.js b/lib/path.js
index 0c9c656e66..c78883bbd3 100644
--- a/lib/path.js
+++ b/lib/path.js
@@ -338,7 +338,7 @@ win32.dirname = function(path) {
win32.basename = function(path, ext) {
if (ext !== undefined && typeof ext !== 'string')
- throw new TypeError('ext must be a string');
+ throw new TypeError('"ext" argument must be a string');
var f = win32SplitPath(path)[2];
// TODO: make this comparison case-insensitive on windows?
@@ -357,7 +357,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
);
}
@@ -365,7 +365,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
);
}
@@ -547,7 +547,7 @@ posix.dirname = function(path) {
posix.basename = function(path, ext) {
if (ext !== undefined && typeof ext !== 'string')
- throw new TypeError('ext must be a string');
+ throw new TypeError('"ext" argument must be a string');
var f = posixSplitPath(path)[2];
@@ -574,7 +574,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
);
}
diff --git a/lib/readline.js b/lib/readline.js
index 0f9aabb2fe..1dbc81d006 100644
--- a/lib/readline.js
+++ b/lib/readline.js
@@ -50,13 +50,13 @@ function Interface(input, output, completer, terminal) {
historySize = historySize || kHistorySize;
if (completer && typeof completer !== 'function') {
- throw new TypeError('Argument \'completer\' must be a function');
+ throw new TypeError('Argument "completer" must be a function');
}
if (typeof historySize !== 'number' ||
isNaN(historySize) ||
historySize < 0) {
- throw new TypeError('Argument \'historySize\' must be a positive number');
+ throw new TypeError('Argument "historySize" must be a positive number');
}
// backwards compat; check the isTTY prop of the output stream
@@ -213,7 +213,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);
@@ -1270,7 +1270,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 f17a926077..3b82474f61 100644
--- a/lib/repl.js
+++ b/lib/repl.js
@@ -897,7 +897,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" command must be a function');
}
this.commands[keyword] = cmd;
};
diff --git a/lib/timers.js b/lib/timers.js
index b75b7ccfc0..0b1ce934d4 100644
--- a/lib/timers.js
+++ b/lib/timers.js
@@ -149,11 +149,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 f3f84ca5a6..c12036e51d 100644
--- a/lib/tty.js
+++ b/lib/tty.js
@@ -17,7 +17,7 @@ exports.isatty = function(fd) {
// backwards-compat
exports.setRawMode = internalUtil.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 is deprecated. ' +
diff --git a/lib/url.js b/lib/url.js
index 45155fee93..f576eb8579 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.
@@ -354,7 +354,7 @@ function urlFormat(obj) {
if (typeof obj === 'string') obj = urlParse(obj);
else if (typeof obj !== 'object' || obj === null)
- throw new TypeError("Parameter 'urlObj' must be an object, not " +
+ throw new TypeError('Parameter "urlObj" must be an object, not ' +
obj === null ? 'null' : typeof obj);
else if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
diff --git a/lib/util.js b/lib/util.js
index 9a68ea0068..4eb7a4a096 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -745,16 +745,16 @@ exports.log = function() {
exports.inherits = function(ctor, superCtor) {
if (ctor === undefined || ctor === null)
- throw new TypeError('The constructor to `inherits` must not be ' +
- 'null or undefined.');
+ throw new TypeError('The constructor to "inherits" must not be ' +
+ 'null or undefined');
if (superCtor === undefined || superCtor === null)
- throw new TypeError('The super constructor to `inherits` must not ' +
- 'be null or undefined.');
+ throw new TypeError('The super constructor to "inherits" must not ' +
+ 'be null or undefined');
if (superCtor.prototype === undefined)
- throw new TypeError('The super constructor to `inherits` must ' +
- 'have a prototype.');
+ throw new TypeError('The super constructor to "inherits" must ' +
+ 'have a prototype');
ctor.super_ = superCtor;
Object.setPrototypeOf(ctor.prototype, superCtor.prototype);
diff --git a/lib/zlib.js b/lib/zlib.js
index a10d9118d6..c6c024220b 100644
--- a/lib/zlib.js
+++ b/lib/zlib.js
@@ -7,7 +7,7 @@ const util = require('util');
const assert = require('assert').ok;
const kMaxLength = require('buffer').kMaxLength;
const kRangeErrorMessage = 'Cannot create final Buffer. ' +
- 'It would be larger than 0x' + kMaxLength.toString(16) + ' bytes.';
+ 'It would be larger than 0x' + kMaxLength.toString(16) + ' bytes';
// zlib doesn't provide these, so kludge them in following the same
// const naming scheme zlib uses.