Capture rate limit and ref not existing config errors

This commit is contained in:
Henry Mercer 2024-04-12 18:25:10 +01:00
parent 5a599c68cf
commit fa75c144b4
6 changed files with 30 additions and 6 deletions

View file

@ -5,10 +5,12 @@ import consoleLogLevel from "console-log-level";
import { getActionVersion, getRequiredInput } from "./actions-util";
import {
ConfigurationError,
getRequiredEnvParam,
GITHUB_DOTCOM_URL,
GitHubVariant,
GitHubVersion,
isHTTPError,
parseGitHubUrl,
parseMatrixInput,
} from "./util";
@ -192,3 +194,15 @@ export function computeAutomationID(
return automationID;
}
export function wrapApiConfigurationError(e: unknown) {
if (isHTTPError(e)) {
if (
e.message.includes("API rate limit exceeded for site ID installation") ||
/^ref .* not found in this repository$/.test(e.message)
) {
return new ConfigurationError(e.message);
}
}
return e;
}

View file

@ -10,7 +10,7 @@ import * as jsonschema from "jsonschema";
import * as actionsUtil from "./actions-util";
import { getOptionalInput, getRequiredInput } from "./actions-util";
import * as api from "./api-client";
import { getGitHubVersion } from "./api-client";
import { getGitHubVersion, wrapApiConfigurationError } from "./api-client";
import { CodeQL, getCodeQL } from "./codeql";
import { getConfig } from "./config-utils";
import { EnvVar } from "./environment";
@ -256,7 +256,7 @@ async function uploadPayload(
break;
}
}
throw e;
throw wrapApiConfigurationError(e);
}
}