diff --git a/lib/dns.js b/lib/dns.js index af2d124dbb39b4..e77542457b5cd1 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -24,7 +24,8 @@ function errnoException(err, syscall, hostname) { } var ex = null; if (typeof err === 'string') { // c-ares error code. - ex = new Error(syscall + ' ' + err + (hostname ? ' ' + hostname : '')); + const errHost = hostname ? ' ' + hostname : ''; + ex = new Error(`${syscall} ${err}${errHost}`); ex.code = err; ex.errno = err; ex.syscall = syscall; @@ -271,7 +272,7 @@ exports.resolve = function(hostname, type_, callback_) { if (typeof resolver === 'function') { return resolver(hostname, callback); } else { - throw new Error('Unknown type "' + type_ + '"'); + throw new Error(`Unknown type "${type_}"`); } }; @@ -309,7 +310,7 @@ exports.setServers = function(servers) { if (ver) return newSet.push([ver, s]); - throw new Error('IP address is not properly formatted: ' + serv); + throw new Error(`IP address is not properly formatted: ${serv}`); }); var r = cares.setServers(newSet); @@ -319,8 +320,7 @@ exports.setServers = function(servers) { cares.setServers(orig.join(',')); var err = cares.strerror(r); - throw new Error('c-ares failed to set servers: "' + err + - '" [' + servers + ']'); + throw new Error(`c-ares failed to set servers: "${err}" [${servers}]`); } };