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:
Angela P Wen 2024-02-08 09:20:03 -08:00 committed by GitHub
parent fc9f9e5ef9
commit 1515e2bb20
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
54 changed files with 654 additions and 502 deletions

14
lib/status-report.js generated
View file

@ -33,14 +33,14 @@ const util_1 = require("./util");
/** Overall status of the entire job. String values match the Hydro schema. */
var JobStatus;
(function (JobStatus) {
JobStatus["Unknown"] = "JOB_STATUS_UNKNOWN";
JobStatus["Success"] = "JOB_STATUS_SUCCESS";
JobStatus["Failure"] = "JOB_STATUS_FAILURE";
JobStatus["ConfigurationError"] = "JOB_STATUS_CONFIGURATION_ERROR";
JobStatus["UnknownStatus"] = "JOB_STATUS_UNKNOWN";
JobStatus["SuccessStatus"] = "JOB_STATUS_SUCCESS";
JobStatus["FailureStatus"] = "JOB_STATUS_FAILURE";
JobStatus["ConfigErrorStatus"] = "JOB_STATUS_CONFIGURATION_ERROR";
})(JobStatus || (exports.JobStatus = JobStatus = {}));
function getActionsStatus(error, otherFailureCause) {
if (error || otherFailureCause) {
return error instanceof util_1.UserError ? "user-error" : "failure";
return error instanceof util_1.ConfigurationError ? "user-error" : "failure";
}
else {
return "success";
@ -54,10 +54,10 @@ exports.getActionsStatus = getActionsStatus;
*/
function setJobStatusIfUnsuccessful(actionStatus) {
if (actionStatus === "user-error") {
core.exportVariable(environment_1.EnvVar.JOB_STATUS, process.env[environment_1.EnvVar.JOB_STATUS] ?? JobStatus.ConfigurationError);
core.exportVariable(environment_1.EnvVar.JOB_STATUS, process.env[environment_1.EnvVar.JOB_STATUS] ?? JobStatus.ConfigErrorStatus);
}
else if (actionStatus === "failure" || actionStatus === "aborted") {
core.exportVariable(environment_1.EnvVar.JOB_STATUS, process.env[environment_1.EnvVar.JOB_STATUS] ?? JobStatus.Failure);
core.exportVariable(environment_1.EnvVar.JOB_STATUS, process.env[environment_1.EnvVar.JOB_STATUS] ?? JobStatus.FailureStatus);
}
}
/**