Skip to content

Commit b5f5380

Browse files
BridgeARMayaLekova
authored andcommittedMay 8, 2018
errors: simplify sysError
PR-URL: nodejs#18857 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
1 parent 55b559f commit b5f5380

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed
 

‎lib/internal/errors.js

+16-21
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ E('ERR_STREAM_UNSHIFT_AFTER_END_EVENT',
841841
'stream.unshift() after end event', Error);
842842
E('ERR_STREAM_WRAP', 'Stream has StringDecoder set or is in objectMode', Error);
843843
E('ERR_STREAM_WRITE_AFTER_END', 'write after end', Error);
844-
E('ERR_SYSTEM_ERROR', sysError('A system error occurred'));
844+
E('ERR_SYSTEM_ERROR', sysError);
845845
E('ERR_TLS_CERT_ALTNAME_INVALID',
846846
'Hostname/IP does not match certificate\'s altnames: %s', Error);
847847
E('ERR_TLS_DH_PARAM_SIZE', 'DH parameter size %s is less than 2048', Error);
@@ -902,26 +902,21 @@ E('ERR_VM_MODULE_STATUS', 'Module status %s', Error);
902902
E('ERR_ZLIB_BINDING_CLOSED', 'zlib binding closed', Error);
903903
E('ERR_ZLIB_INITIALIZATION_FAILED', 'Initialization failed', Error);
904904

905-
function sysError(defaultMessage) {
906-
return function(code,
907-
syscall,
908-
path,
909-
dest,
910-
message = defaultMessage) {
911-
if (code !== undefined)
912-
message += `: ${code}`;
913-
if (syscall !== undefined) {
914-
if (code === undefined)
915-
message += ':';
916-
message += ` [${syscall}]`;
917-
}
918-
if (path !== undefined) {
919-
message += `: ${path}`;
920-
if (dest !== undefined)
921-
message += ` => ${dest}`;
922-
}
923-
return message;
924-
};
905+
function sysError(code, syscall, path, dest,
906+
message = 'A system error occurred') {
907+
if (code !== undefined)
908+
message += `: ${code}`;
909+
if (syscall !== undefined) {
910+
if (code === undefined)
911+
message += ':';
912+
message += ` [${syscall}]`;
913+
}
914+
if (path !== undefined) {
915+
message += `: ${path}`;
916+
if (dest !== undefined)
917+
message += ` => ${dest}`;
918+
}
919+
return message;
925920
}
926921

927922
function invalidArgType(name, expected, actual) {

0 commit comments

Comments
 (0)