| | |
| | | var _this = _super.call(this, message(key, args)) || this; |
| | | _this.code = key; |
| | | _this[kCode] = key; |
| | | _this.name = _super.prototype.name + " [" + _this[kCode] + "]"; |
| | | _this.name = "".concat(_super.prototype.name, " [").concat(_this[kCode], "]"); |
| | | return _this; |
| | | } |
| | | return NodeError; |
| | |
| | | _this = _super.call(this, options.message) || this; |
| | | } |
| | | else { |
| | | _this = _super.call(this, util.inspect(options.actual).slice(0, 128) + " " + |
| | | (options.operator + " " + util.inspect(options.expected).slice(0, 128))) || this; |
| | | _this = _super.call(this, "".concat(util.inspect(options.actual).slice(0, 128), " ") + |
| | | "".concat(options.operator, " ").concat(util.inspect(options.expected).slice(0, 128))) || this; |
| | | } |
| | | _this.generatedMessage = !options.message; |
| | | _this.name = 'AssertionError [ERR_ASSERTION]'; |
| | |
| | | assert.strictEqual(typeof key, 'string'); |
| | | // const msg = messages.get(key); |
| | | var msg = messages[key]; |
| | | assert(msg, "An invalid error message key was used: " + key + "."); |
| | | assert(msg, "An invalid error message key was used: ".concat(key, ".")); |
| | | var fmt; |
| | | if (typeof msg === 'function') { |
| | | fmt = msg; |
| | |
| | | E('ERR_CHILD_CLOSED_BEFORE_REPLY', 'Child closed before reply received'); |
| | | E('ERR_CONSOLE_WRITABLE_STREAM', 'Console expects a writable stream instance for %s'); |
| | | E('ERR_CPU_USAGE', 'Unable to obtain cpu usage %s'); |
| | | E('ERR_DNS_SET_SERVERS_FAILED', function (err, servers) { return "c-ares failed to set servers: \"" + err + "\" [" + servers + "]"; }); |
| | | E('ERR_DNS_SET_SERVERS_FAILED', function (err, servers) { return "c-ares failed to set servers: \"".concat(err, "\" [").concat(servers, "]"); }); |
| | | E('ERR_FALSY_VALUE_REJECTION', 'Promise was rejected with falsy value'); |
| | | E('ERR_ENCODING_NOT_SUPPORTED', function (enc) { return "The \"" + enc + "\" encoding is not supported"; }); |
| | | E('ERR_ENCODING_INVALID_ENCODED_DATA', function (enc) { return "The encoded data was not valid for encoding " + enc; }); |
| | | E('ERR_ENCODING_NOT_SUPPORTED', function (enc) { return "The \"".concat(enc, "\" encoding is not supported"); }); |
| | | E('ERR_ENCODING_INVALID_ENCODED_DATA', function (enc) { return "The encoded data was not valid for encoding ".concat(enc); }); |
| | | E('ERR_HTTP_HEADERS_SENT', 'Cannot render headers after they are sent to the client'); |
| | | E('ERR_HTTP_INVALID_STATUS_CODE', 'Invalid status code: %s'); |
| | | E('ERR_HTTP_TRAILER_INVALID', 'Trailers are invalid with this transfer encoding'); |
| | |
| | | E('ERR_INVALID_ARG_TYPE', invalidArgType); |
| | | E('ERR_INVALID_ARRAY_LENGTH', function (name, len, actual) { |
| | | assert.strictEqual(typeof actual, 'number'); |
| | | return "The array \"" + name + "\" (length " + actual + ") must be of length " + len + "."; |
| | | return "The array \"".concat(name, "\" (length ").concat(actual, ") must be of length ").concat(len, "."); |
| | | }); |
| | | E('ERR_INVALID_BUFFER_SIZE', 'Buffer size must be a multiple of %s'); |
| | | E('ERR_INVALID_CALLBACK', 'Callback must be a function'); |
| | |
| | | E('ERR_INVALID_HANDLE_TYPE', 'This handle type cannot be sent'); |
| | | E('ERR_INVALID_IP_ADDRESS', 'Invalid IP address: %s'); |
| | | E('ERR_INVALID_OPT_VALUE', function (name, value) { |
| | | return "The value \"" + String(value) + "\" is invalid for option \"" + name + "\""; |
| | | return "The value \"".concat(String(value), "\" is invalid for option \"").concat(name, "\""); |
| | | }); |
| | | E('ERR_INVALID_OPT_VALUE_ENCODING', function (value) { return "The value \"" + String(value) + "\" is invalid for option \"encoding\""; }); |
| | | E('ERR_INVALID_OPT_VALUE_ENCODING', function (value) { return "The value \"".concat(String(value), "\" is invalid for option \"encoding\""); }); |
| | | E('ERR_INVALID_REPL_EVAL_CONFIG', 'Cannot specify both "breakEvalOnSigint" and "eval" for REPL'); |
| | | E('ERR_INVALID_SYNC_FORK_INPUT', 'Asynchronous forks do not support Buffer, Uint8Array or string input: %s'); |
| | | E('ERR_INVALID_THIS', 'Value of "this" must be of type %s'); |
| | | E('ERR_INVALID_TUPLE', '%s must be an iterable %s tuple'); |
| | | E('ERR_INVALID_URL', 'Invalid URL: %s'); |
| | | E('ERR_INVALID_URL_SCHEME', function (expected) { return "The URL must be " + oneOf(expected, 'scheme'); }); |
| | | E('ERR_INVALID_URL_SCHEME', function (expected) { return "The URL must be ".concat(oneOf(expected, 'scheme')); }); |
| | | E('ERR_IPC_CHANNEL_CLOSED', 'Channel closed'); |
| | | E('ERR_IPC_DISCONNECTED', 'IPC channel is already disconnected'); |
| | | E('ERR_IPC_ONE_PIPE', 'Child process can have only one IPC pipe'); |
| | |
| | | E('ERR_STDOUT_CLOSE', 'process.stdout cannot be closed'); |
| | | E('ERR_STREAM_WRAP', 'Stream has StringDecoder set or is in objectMode'); |
| | | E('ERR_TLS_CERT_ALTNAME_INVALID', "Hostname/IP does not match certificate's altnames: %s"); |
| | | E('ERR_TLS_DH_PARAM_SIZE', function (size) { return "DH parameter size " + size + " is less than 2048"; }); |
| | | E('ERR_TLS_DH_PARAM_SIZE', function (size) { return "DH parameter size ".concat(size, " is less than 2048"); }); |
| | | E('ERR_TLS_HANDSHAKE_TIMEOUT', 'TLS handshake timeout'); |
| | | E('ERR_TLS_RENEGOTIATION_FAILED', 'Failed to renegotiate'); |
| | | E('ERR_TLS_REQUIRED_SERVER_NAME', '"servername" is required parameter for Server.addContext'); |
| | |
| | | } |
| | | var msg; |
| | | if (Array.isArray(name)) { |
| | | var names = name.map(function (val) { return "\"" + val + "\""; }).join(', '); |
| | | msg = "The " + names + " arguments " + determiner + " " + oneOf(expected, 'type'); |
| | | var names = name.map(function (val) { return "\"".concat(val, "\""); }).join(', '); |
| | | msg = "The ".concat(names, " arguments ").concat(determiner, " ").concat(oneOf(expected, 'type')); |
| | | } |
| | | else if (name.includes(' argument')) { |
| | | // for the case like 'first argument' |
| | | msg = "The " + name + " " + determiner + " " + oneOf(expected, 'type'); |
| | | msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); |
| | | } |
| | | else { |
| | | var type = name.includes('.') ? 'property' : 'argument'; |
| | | msg = "The \"" + name + "\" " + type + " " + determiner + " " + oneOf(expected, 'type'); |
| | | msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); |
| | | } |
| | | // if actual value received, output it |
| | | if (arguments.length >= 3) { |
| | | msg += ". Received type " + (actual !== null ? typeof actual : 'null'); |
| | | msg += ". Received type ".concat(actual !== null ? typeof actual : 'null'); |
| | | } |
| | | return msg; |
| | | } |
| | |
| | | assert(args.length > 0, 'At least one arg needs to be specified'); |
| | | var msg = 'The '; |
| | | var len = args.length; |
| | | args = args.map(function (a) { return "\"" + a + "\""; }); |
| | | args = args.map(function (a) { return "\"".concat(a, "\""); }); |
| | | switch (len) { |
| | | case 1: |
| | | msg += args[0] + " argument"; |
| | | msg += "".concat(args[0], " argument"); |
| | | break; |
| | | case 2: |
| | | msg += args[0] + " and " + args[1] + " arguments"; |
| | | msg += "".concat(args[0], " and ").concat(args[1], " arguments"); |
| | | break; |
| | | default: |
| | | msg += args.slice(0, len - 1).join(', '); |
| | | msg += ", and " + args[len - 1] + " arguments"; |
| | | msg += ", and ".concat(args[len - 1], " arguments"); |
| | | break; |
| | | } |
| | | return msg + " must be specified"; |
| | | return "".concat(msg, " must be specified"); |
| | | } |
| | | function oneOf(expected, thing) { |
| | | assert(expected, 'expected is required'); |
| | |
| | | // tslint:disable-next-line |
| | | expected = expected.map(function (i) { return String(i); }); |
| | | if (len > 2) { |
| | | return "one of " + thing + " " + expected.slice(0, len - 1).join(', ') + ", or " + expected[len - 1]; |
| | | return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1]; |
| | | } |
| | | else if (len === 2) { |
| | | return "one of " + thing + " " + expected[0] + " or " + expected[1]; |
| | | return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]); |
| | | } |
| | | else { |
| | | return "of " + thing + " " + expected[0]; |
| | | return "of ".concat(thing, " ").concat(expected[0]); |
| | | } |
| | | } |
| | | else { |
| | | return "of " + thing + " " + String(expected); |
| | | return "of ".concat(thing, " ").concat(String(expected)); |
| | | } |
| | | } |
| | | function bufferOutOfBounds(name, isWriting) { |
| | |
| | | return 'Attempt to write outside buffer bounds'; |
| | | } |
| | | else { |
| | | return "\"" + name + "\" is outside of buffer bounds"; |
| | | return "\"".concat(name, "\" is outside of buffer bounds"); |
| | | } |
| | | } |