dns: use template literals

Prefer the use of template string literals over string concatenation
in the dns module, makes dns consistent with other modules basically
doing https://github.com/nodejs/node/pull/5778 for it.

PR-URL: https://github.com/nodejs/node/pull/5809
Reviewed-By: James M Snell <jasnell@gmail.com>
pull/5809/merge
Benjamin Gruenbaum 2016-03-20 15:13:51 +02:00
parent c979a2d447
commit 8baaa25aec
1 changed files with 5 additions and 5 deletions

View File

@ -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}]`);
}
};