mirror of
https://github.com/github/codeql-action.git
synced 2026-01-04 13:40:23 +08:00
Refactor configuration errors (#2105)
Refactor the existing classes of configuration errors into their own file; consolidate the place we check for configuration errors into `codeql.ts`, where the actual command invocations happen. Also, rename the `UserError` type to `ConfigurationError` to standardize on a single term.
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
doesDirectoryExist,
|
||||
getCodeQLDatabasePath,
|
||||
getRequiredEnvParam,
|
||||
UserError,
|
||||
ConfigurationError,
|
||||
} from "./util";
|
||||
|
||||
// eslint-disable-next-line import/no-commonjs
|
||||
@@ -26,7 +26,7 @@ const pkg = require("../package.json") as JSONSchemaForNPMPackageJsonFiles;
|
||||
export const getRequiredInput = function (name: string): string {
|
||||
const value = core.getInput(name);
|
||||
if (!value) {
|
||||
throw new UserError(`Input required and not supplied: ${name}`);
|
||||
throw new ConfigurationError(`Input required and not supplied: ${name}`);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
@@ -187,7 +187,7 @@ export async function getRef(): Promise<string> {
|
||||
const hasShaInput = !!shaInput;
|
||||
// If one of 'ref' or 'sha' are provided, both are required
|
||||
if ((hasRefInput || hasShaInput) && !(hasRefInput && hasShaInput)) {
|
||||
throw new UserError(
|
||||
throw new ConfigurationError(
|
||||
"Both 'ref' and 'sha' are required if one of them is provided.",
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user