2017-12-18 08:39:52 +00:00
|
|
|
const { raiseConfigWarningIssue } = require('./error-config');
|
2018-06-28 08:17:17 +00:00
|
|
|
const { raiseLockFileIssue } = require('./error-lockfile');
|
2017-12-18 08:39:52 +00:00
|
|
|
|
2017-11-05 04:45:49 +00:00
|
|
|
module.exports = {
|
|
|
|
handleError,
|
|
|
|
};
|
|
|
|
|
2017-12-18 08:39:52 +00:00
|
|
|
async function handleError(config, err) {
|
2017-11-05 04:45:49 +00:00
|
|
|
if (err.message === 'uninitiated') {
|
|
|
|
logger.info('Repository is uninitiated - skipping');
|
2017-11-05 05:27:46 +00:00
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
2017-11-05 04:45:49 +00:00
|
|
|
return err.message;
|
|
|
|
} else if (err.message === 'disabled') {
|
|
|
|
logger.info('Repository is disabled - skipping');
|
|
|
|
return err.message;
|
2017-12-31 19:28:22 +00:00
|
|
|
} else if (err.message === 'archived') {
|
|
|
|
logger.info('Repository is archived - skipping');
|
2018-02-04 20:20:28 +00:00
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
2018-02-08 15:04:25 +00:00
|
|
|
return err.message;
|
|
|
|
} else if (err.message === 'renamed') {
|
|
|
|
logger.info('Repository has been renamed - skipping');
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
2017-12-31 19:28:22 +00:00
|
|
|
return err.message;
|
2018-02-02 17:04:26 +00:00
|
|
|
} else if (err.message === 'blocked') {
|
2018-02-04 20:57:43 +00:00
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
2018-02-02 17:04:26 +00:00
|
|
|
logger.info('Repository is blocked - skipping');
|
|
|
|
return err.message;
|
2018-02-05 21:23:50 +00:00
|
|
|
} else if (err.message === 'forbidden') {
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
|
|
|
logger.info('Repository is forbidden');
|
|
|
|
return err.message;
|
2017-12-31 19:47:46 +00:00
|
|
|
} else if (err.message === 'not-found') {
|
2018-02-04 20:57:43 +00:00
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
2018-03-09 10:50:04 +00:00
|
|
|
logger.error('Repository is not found');
|
2017-12-31 19:47:46 +00:00
|
|
|
return err.message;
|
2017-11-05 04:45:49 +00:00
|
|
|
} else if (err.message === 'fork') {
|
|
|
|
logger.info('Repository is a fork and not manually configured - skipping');
|
|
|
|
return err.message;
|
|
|
|
} else if (err.message === 'no-package-files') {
|
|
|
|
logger.info('Repository has no package files - skipping');
|
|
|
|
return err.message;
|
2018-02-03 14:45:43 +00:00
|
|
|
} else if (err.message === 'repository-changed') {
|
2018-02-09 07:27:24 +00:00
|
|
|
logger.info('Repository has changed during renovation - aborting');
|
2018-02-03 14:45:43 +00:00
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
|
|
|
return err.message;
|
2017-12-18 08:39:52 +00:00
|
|
|
} else if (err.message === 'config-validation') {
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
|
|
|
logger.info({ error: err }, 'Repository has invalid config');
|
|
|
|
await raiseConfigWarningIssue(config, err);
|
|
|
|
return err.message;
|
2018-01-14 17:58:49 +00:00
|
|
|
} else if (err.message === 'registry-failure') {
|
|
|
|
logger.info('Registry error - skipping');
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
|
|
|
return err.message;
|
2018-03-22 08:26:20 +00:00
|
|
|
} else if (err.message === 'rate-limit-exceeded') {
|
|
|
|
logger.warn('Rate limit exceeded - aborting');
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
|
|
|
return err.message;
|
2018-05-24 14:28:36 +00:00
|
|
|
} else if (err.message === 'lockfile-error') {
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
2018-06-28 08:17:17 +00:00
|
|
|
await raiseLockFileIssue(err);
|
2018-05-24 14:28:36 +00:00
|
|
|
return err.message;
|
2017-11-05 04:45:49 +00:00
|
|
|
}
|
|
|
|
// Swallow this error so that other repositories can be processed
|
2018-01-26 18:08:13 +00:00
|
|
|
logger.error(
|
2018-03-20 17:03:14 +00:00
|
|
|
{
|
|
|
|
err,
|
|
|
|
message: err.message,
|
|
|
|
body: err.response ? err.response.body : undefined,
|
|
|
|
},
|
|
|
|
`Repository has unknown error`
|
2018-01-26 18:08:13 +00:00
|
|
|
);
|
2017-11-05 04:45:49 +00:00
|
|
|
// delete branchList to avoid cleaning up branches
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
2018-04-10 07:18:39 +00:00
|
|
|
logger.info({ err, message: err.message }, 'Unknown error');
|
2017-11-05 04:45:49 +00:00
|
|
|
return 'unknown-error';
|
|
|
|
}
|