Skip to content

Commit

Permalink
dns: use template literals
Browse files Browse the repository at this point in the history
Prefer the use of template string literals over string concatenation
in the dns module, makes dns consistent with other modules basically
doing #5778 for it.

PR-URL: #5809
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
benjamingr authored and Fishrock123 committed Mar 22, 2016
1 parent ca971b0 commit 7d1918b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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;
Expand Down Expand Up @@ -267,7 +268,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_}"`);
}
};

Expand Down Expand Up @@ -305,7 +306,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);
Expand All @@ -315,8 +316,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}]`);
}
};

Expand Down

0 comments on commit 7d1918b

Please sign in to comment.