Skip to content

Commit 474c498

Browse files
committed
errors: simplify sysError
1 parent ae87200 commit 474c498

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
@@ -842,7 +842,7 @@ E('ERR_STREAM_UNSHIFT_AFTER_END_EVENT',
842842
'stream.unshift() after end event', Error);
843843
E('ERR_STREAM_WRAP', 'Stream has StringDecoder set or is in objectMode', Error);
844844
E('ERR_STREAM_WRITE_AFTER_END', 'write after end', Error);
845-
E('ERR_SYSTEM_ERROR', sysError('A system error occurred'));
845+
E('ERR_SYSTEM_ERROR', sysError);
846846
E('ERR_TLS_CERT_ALTNAME_INVALID',
847847
'Hostname/IP does not match certificate\'s altnames: %s', Error);
848848
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);
903903
E('ERR_ZLIB_BINDING_CLOSED', 'zlib binding closed', Error);
904904
E('ERR_ZLIB_INITIALIZATION_FAILED', 'Initialization failed', Error);
905905

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

928923
function invalidArgType(name, expected, actual) {

0 commit comments

Comments
 (0)