diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 481c929c707ea2..6b0339865affc5 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -842,7 +842,7 @@ E('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event', Error); E('ERR_STREAM_WRAP', 'Stream has StringDecoder set or is in objectMode', Error); E('ERR_STREAM_WRITE_AFTER_END', 'write after end', Error); -E('ERR_SYSTEM_ERROR', sysError('A system error occurred')); +E('ERR_SYSTEM_ERROR', sysError); E('ERR_TLS_CERT_ALTNAME_INVALID', 'Hostname/IP does not match certificate\'s altnames: %s', Error); E('ERR_TLS_DH_PARAM_SIZE', 'DH parameter size %s is less than 2048', Error); @@ -903,26 +903,21 @@ E('ERR_VM_MODULE_STATUS', 'Module status %s', Error); E('ERR_ZLIB_BINDING_CLOSED', 'zlib binding closed', Error); E('ERR_ZLIB_INITIALIZATION_FAILED', 'Initialization failed', Error); -function sysError(defaultMessage) { - return function(code, - syscall, - path, - dest, - message = defaultMessage) { - if (code !== undefined) - message += `: ${code}`; - if (syscall !== undefined) { - if (code === undefined) - message += ':'; - message += ` [${syscall}]`; - } - if (path !== undefined) { - message += `: ${path}`; - if (dest !== undefined) - message += ` => ${dest}`; - } - return message; - }; +function sysError(code, syscall, path, dest, + message = 'A system error occurred') { + if (code !== undefined) + message += `: ${code}`; + if (syscall !== undefined) { + if (code === undefined) + message += ':'; + message += ` [${syscall}]`; + } + if (path !== undefined) { + message += `: ${path}`; + if (dest !== undefined) + message += ` => ${dest}`; + } + return message; } function invalidArgType(name, expected, actual) {