Skip to content

Commit

Permalink
Handle non-200s from conan (#4529)
Browse files Browse the repository at this point in the history
* Handle non-200s from conan
  • Loading branch information
mattgodbolt committed Jan 4, 2023
1 parent 96e7f1d commit 64d68da
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/buildenvsetup/ceconan.ts
Expand Up @@ -175,12 +175,20 @@ export class BuildEnvSetupCeConanDirect extends BuildEnvSetupBase {
encoding: null,
};

request(packageUrl, settings)
// https://stackoverflow.com/questions/49277790/how-to-pipe-npm-request-only-if-http-200-is-received
const req = request(packageUrl, settings)
.on('error', error => {
logger.error(`Error in request handling: ${error}`);
reject(error);
})
.pipe(gunzip);
.on('response', res => {
if (res.statusCode === 200) {
req.pipe(gunzip);
} else {
logger.error(`Error requesting package from conan: ${res.statusCode} for ${packageUrl}`);
reject(new Error(`Unable to request library from conan: ${res.statusCode}`));
}
});
});
}

Expand Down

0 comments on commit 64d68da

Please sign in to comment.