2017-12-18 08:39:52 +00:00
|
|
|
const { raiseConfigWarningIssue } = require('./error-config');
|
|
|
|
|
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');
|
|
|
|
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;
|
|
|
|
} else if (err.message === 'loops>5') {
|
|
|
|
logger.error('Repository has looped 5 times already');
|
|
|
|
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;
|
2017-11-05 04:45:49 +00:00
|
|
|
}
|
|
|
|
// Swallow this error so that other repositories can be processed
|
|
|
|
logger.error({ err }, `Repository has unknown error`);
|
|
|
|
// delete branchList to avoid cleaning up branches
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
|
|
|
return 'unknown-error';
|
|
|
|
}
|