fix(gitlab): throw platform-failure if 5xx

This commit is contained in:
Rhys Arkins 2019-06-05 10:13:00 +02:00
parent 6a11d5f59b
commit f6f7db8d6c
2 changed files with 20 additions and 12 deletions

View file

@ -13,20 +13,28 @@ async function get(path: string, options: any) {
json: true,
...options,
};
const res = await got(path, opts);
if (opts.paginate) {
// Check if result is paginated
try {
const linkHeader = parseLinkHeader(res.headers.link as string);
if (linkHeader && linkHeader.next) {
res.body = res.body.concat((await get(linkHeader.next.url, opts)).body);
try {
const res = await got(path, opts);
if (opts.paginate) {
// Check if result is paginated
try {
const linkHeader = parseLinkHeader(res.headers.link as string);
if (linkHeader && linkHeader.next) {
res.body = res.body.concat(
(await get(linkHeader.next.url, opts)).body
);
}
} catch (err) /* istanbul ignore next */ {
logger.warn({ err }, 'Pagination error');
}
} catch (err) /* istanbul ignore next */ {
logger.warn({ err }, 'Pagination error');
}
return res;
} catch (err) /* istanbul ignore next */ {
if (err.statusCode >= 500 && err.statusCode < 600) {
throw new Error('platform-failure');
}
throw err;
}
return res;
}
const helpers = ['get', 'post', 'put', 'patch', 'head', 'delete'];

View file

@ -1,7 +1,7 @@
const util = require('util');
const glob = util.promisify(require('glob'));
const ignoredExtensions = ['js', 'ts', 'md', 'pyc'];
const ignoredExtensions = ['js', 'ts', 'md', 'pyc', 'DS_Store'];
function filterFiles(files) {
return files.filter(file =>