EvanOxfeld / node-unzip

node.js cross-platform unzip using streams
MIT License
613 stars 343 forks source link

Empty error thrown #74

Closed Cyberuben closed 9 years ago

Cyberuben commented 9 years ago

I'm using the following code:

function DownloadAndExtract(file, callback) {
    log.debug("Starting download of "+file);
    fse.ensureDirSync(tempPath);
    var extractor = unzip.Extract({path: tempPath});
    extractor.on("close", function() {
        log.debug("Done downloading "+file);
        return callback(null, file);
    });
    extractor.on("error", function (err) {
        log.error("Extracting download "+file+": "+JSON.stringify(err, null, "\t"));
        return callback(err, null);
    });

    var url = "";
    if(file == "WONEN") {
        url = "https://example.com/file1.zip";
    }else if(file == "BOG") {
        url = "https://example.com/file2.zip";
    }

    if(url != "") {
        request
            .get(url)
            .on("error", function (err) {
                return callback(err, null);
            })
            .pipe(extractor);
    }else{
        return callback(new Error("Invalid file indicator: '"+file+"'"), null);
    }
}

When checking my log file, I see the following error: 21-02-2015 03:00:05 - [ERROR] Extracting download WONEN: {} This makes me assume an empty error is thrown

Cyberuben commented 9 years ago

I guess this one is my own stupidity