2020-01-11 08:16:22 +00:00
|
|
|
import { logger } from '../../logger';
|
2019-07-15 09:04:05 +00:00
|
|
|
import { raiseConfigWarningIssue } from './error-config';
|
2020-01-10 10:35:49 +00:00
|
|
|
import { RenovateConfig } from '../../config';
|
2017-12-18 08:39:52 +00:00
|
|
|
|
2020-01-10 10:35:49 +00:00
|
|
|
export default async function handleError(
|
|
|
|
config: RenovateConfig,
|
|
|
|
err: Error
|
|
|
|
): Promise<string> {
|
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;
|
2018-07-09 09:28:33 +00:00
|
|
|
}
|
2018-09-25 06:50:47 +00:00
|
|
|
if (err.message === 'empty') {
|
|
|
|
logger.info('Repository is empty - skipping');
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
|
|
|
return err.message;
|
|
|
|
}
|
2018-07-09 09:28:33 +00:00
|
|
|
if (err.message === 'disabled') {
|
2017-11-05 04:45:49 +00:00
|
|
|
logger.info('Repository is disabled - skipping');
|
|
|
|
return err.message;
|
2018-07-09 09:28:33 +00:00
|
|
|
}
|
|
|
|
if (err.message === 'archived') {
|
2017-12-31 19:28:22 +00:00
|
|
|
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;
|
2018-07-09 09:28:33 +00:00
|
|
|
}
|
2019-06-13 04:05:58 +00:00
|
|
|
if (err.message === 'mirror') {
|
|
|
|
logger.info('Repository is a mirror - skipping');
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
|
|
|
return err.message;
|
|
|
|
}
|
2018-07-09 09:28:33 +00:00
|
|
|
if (err.message === 'renamed') {
|
2018-02-08 15:04:25 +00:00
|
|
|
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-07-09 09:28:33 +00:00
|
|
|
}
|
|
|
|
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-07-09 09:28:33 +00:00
|
|
|
}
|
|
|
|
if (err.message === 'forbidden') {
|
2018-02-05 21:23:50 +00:00
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
|
|
|
logger.info('Repository is forbidden');
|
|
|
|
return err.message;
|
2018-07-09 09:28:33 +00:00
|
|
|
}
|
|
|
|
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;
|
2018-07-09 09:28:33 +00:00
|
|
|
}
|
|
|
|
if (err.message === 'fork') {
|
2017-11-05 04:45:49 +00:00
|
|
|
logger.info('Repository is a fork and not manually configured - skipping');
|
|
|
|
return err.message;
|
2018-07-09 09:28:33 +00:00
|
|
|
}
|
2018-10-08 08:41:55 +00:00
|
|
|
if (err.message === 'cannot-fork') {
|
|
|
|
logger.info('Cannot fork repository - skipping');
|
|
|
|
return err.message;
|
|
|
|
}
|
2018-07-09 09:28:33 +00:00
|
|
|
if (err.message === 'no-package-files') {
|
2017-11-05 04:45:49 +00:00
|
|
|
logger.info('Repository has no package files - skipping');
|
|
|
|
return err.message;
|
2018-07-09 09:28:33 +00:00
|
|
|
}
|
2018-07-29 06:43:53 +00:00
|
|
|
if (err.message === 'no-vulnerability-alerts') {
|
|
|
|
logger.info('Repository has no vulnerability alerts - skipping');
|
|
|
|
return err.message;
|
|
|
|
}
|
2018-07-09 09:28:33 +00:00
|
|
|
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;
|
2018-07-09 09:28:33 +00:00
|
|
|
}
|
|
|
|
if (err.message === 'config-validation') {
|
2017-12-18 08:39:52 +00:00
|
|
|
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-07-09 09:28:33 +00:00
|
|
|
}
|
|
|
|
if (err.message === 'registry-failure') {
|
2018-01-14 17:58:49 +00:00
|
|
|
logger.info('Registry error - skipping');
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
2018-07-21 06:38:13 +00:00
|
|
|
return err.message;
|
|
|
|
}
|
|
|
|
if (err.message === 'platform-failure') {
|
|
|
|
logger.info('Platform error - skipping');
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
2018-01-14 17:58:49 +00:00
|
|
|
return err.message;
|
2018-07-09 09:28:33 +00:00
|
|
|
}
|
2019-07-02 05:28:45 +00:00
|
|
|
if (
|
|
|
|
err.message.includes('No space left on device') ||
|
|
|
|
err.message === 'disk-space'
|
|
|
|
) {
|
2018-09-08 05:16:05 +00:00
|
|
|
logger.error('Disk space error - skipping');
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
|
|
|
return err.message;
|
|
|
|
}
|
2018-07-09 09:28:33 +00:00
|
|
|
if (err.message === 'rate-limit-exceeded') {
|
2018-03-22 08:26:20 +00:00
|
|
|
logger.warn('Rate limit exceeded - aborting');
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
|
|
|
return err.message;
|
2019-02-13 21:33:58 +00:00
|
|
|
}
|
|
|
|
if (err.message === 'bad-credentials') {
|
|
|
|
logger.warn('Bad credentials - aborting');
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
|
|
|
return err.message;
|
2018-07-09 09:28:33 +00:00
|
|
|
}
|
2018-12-03 11:03:46 +00:00
|
|
|
if (err.message === 'integration-unauthorized') {
|
|
|
|
logger.warn('Integration unauthorized - aborting');
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
|
|
|
return err.message;
|
|
|
|
}
|
2019-02-02 01:46:32 +00:00
|
|
|
if (err.message === 'authentication-error') {
|
|
|
|
logger.warn('Authentication error - aborting');
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
|
|
|
return err.message;
|
|
|
|
}
|
2019-03-16 06:55:39 +00:00
|
|
|
if (err.message === 'temporary-error') {
|
|
|
|
logger.info('Temporary error - aborting');
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
|
|
|
return err.message;
|
|
|
|
}
|
2018-07-09 09:28:33 +00:00
|
|
|
if (err.message === 'lockfile-error') {
|
2018-05-24 14:28:36 +00:00
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
2018-07-14 05:50:37 +00:00
|
|
|
logger.info('Lock file error - aborting');
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
2018-05-24 14:28:36 +00:00
|
|
|
return err.message;
|
2017-11-05 04:45:49 +00:00
|
|
|
}
|
2019-06-12 09:44:29 +00:00
|
|
|
if (err.message.includes('The requested URL returned error: 5')) {
|
2019-06-12 14:14:44 +00:00
|
|
|
logger.warn({ err }, 'Git error - aborting');
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
|
|
|
// rewrite this error
|
|
|
|
return 'platform-failure';
|
|
|
|
}
|
|
|
|
if (
|
|
|
|
err.message.includes('The remote end hung up unexpectedly') ||
|
|
|
|
err.message.includes('access denied or repository not exported')
|
|
|
|
) {
|
|
|
|
logger.warn({ err }, 'Git error - aborting');
|
2019-06-12 08:49:21 +00:00
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
|
|
|
// rewrite this error
|
|
|
|
return 'platform-failure';
|
|
|
|
}
|
2017-11-05 04:45:49 +00:00
|
|
|
// Swallow this error so that other repositories can be processed
|
2018-09-05 08:31:21 +00:00
|
|
|
logger.error({ err }, `Repository has unknown error`);
|
2017-11-05 04:45:49 +00:00
|
|
|
// delete branchList to avoid cleaning up branches
|
|
|
|
delete config.branchList; // eslint-disable-line no-param-reassign
|
|
|
|
return 'unknown-error';
|
|
|
|
}
|