Skip to content
This repository has been archived by the owner on Mar 27, 2019. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
add friendlier dns lookup error message
  • Loading branch information
tj committed Aug 23, 2012
1 parent 24c3a4a commit 4b1f140
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/Package.js
Expand Up @@ -121,8 +121,9 @@ Package.prototype.getLocalJSON = function(fn){
Package.prototype.getJSON = function(fn){
var self = this;
var url = this.url('component.json');

debug('fetching %s', url);
request.get(url, function(res){
var req = request.get(url, function(res){
if (res.ok) {
debug('got %s', url);
try {
Expand All @@ -135,6 +136,11 @@ Package.prototype.getJSON = function(fn){
fn(new Error('failed to fetch ' + url));
}
});

req.on('error', function(err){
if ('getaddrinfo' == err.syscall) err.message = 'dns lookup failed';
fn(err);
});
};

/**
Expand Down

0 comments on commit 4b1f140

Please sign in to comment.