@@ -35,27 +35,26 @@ function download(destinationPath, url, callback)
35 requestWithRedirects(url, 10,
35 requestWithRedirects(url, 10,
36 function(error) {
36 function(error) {
37 var url = host + '/' + path;
37 var url = host + '/' + path;
38− throw new Error('Error fetching binary from ' + url + ': ' + error);
38+ exitFailure(url, 'Error fetching binary from ' + url + ': ' + error);
40 function(response) {
40 function(response) {
41 if (response.statusCode == 404)
41 if (response.statusCode == 404)
43− // TODO give specific error message
43+ exitFailure(url, 'I got a "404 Not Found" trying to download from the following URL:\n' + url);
44− throw new Error('Not Found: ' + url);
47 response.on('error', function() {
46 response.on('error', function() {
48− throw new Error('Error receiving ' + url);
47+ exitFailure(url, 'Something went wrong while receiving the following URL:\n\n' + url);
51 var gunzip = zlib.createGunzip().on('error', function(error) {
50 var gunzip = zlib.createGunzip().on('error', function(error) {
52− throw new Error('Error decompressing elm.gz: ' + error);
51+ exitFailure(url, 'I ran into trouble decompressing the downloaded binary. It is saying:\n\n' + error);
54 var write = fs.createWriteStream(destinationPath, {
53 var write = fs.createWriteStream(destinationPath, {
55 encoding: 'binary',
54 encoding: 'binary',
56 mode: 0o755
55 mode: 0o755
57 }).on('finish', callback).on('error', function(error) {
56 }).on('finish', callback).on('error', function(error) {
58− throw new Error('Error writing file: ' + error);
57+ exitFailure(url, 'I had some trouble writing file to disk. It is saying:\n\n' + error);
61 response.pipe(gunzip).pipe(write);
60 response.pipe(gunzip).pipe(write);
@@ -93,3 +92,20 @@ function requestWithRedirects(url, maxRedirects, failure, success)
94 req.end();
93 req.end();
101+function exitFailure(url, message)
104+ '-- ERROR -----------------------------------------------------------------------\n\n'
106+ + '\n\nNOTE: You can avoid npm entirely by downloading directly from:\n'
107+ + url + '\nAll this package does is download that file and put it somewhere.\n\n'
108+ + '--------------------------------------------------------------------------------\n'