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 <jasnell@gmail.com>
  • Loading branch information
benjamingr committed Mar 22, 2016
1 parent c979a2d commit 8baaa25
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 @@ -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;
Expand Down Expand Up @@ -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_}"`);
}
};

Expand Down Expand Up @@ -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);
Expand All @@ -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}]`);
}
};

Expand Down

0 comments on commit 8baaa25

Please sign in to comment.