mirror of
https://github.com/github/codeql-action.git
synced 2025-12-24 08:10:06 +08:00
Ensure loadApiError is caught
And add a better error message. By using `void` instead of `await`, any error thrown is not caught by surrounding try-catch blocks. I could continue to use `void` and explicitly handle any thrown errors by using `.catch`, but most likely the time savings is minimal and this makes the code more complex.
This commit is contained in:
19
lib/feature-flags.js
generated
19
lib/feature-flags.js
generated
@@ -62,11 +62,20 @@ class GitHubFeatureFlags {
|
||||
return response.data;
|
||||
}
|
||||
catch (e) {
|
||||
// Some feature flags, such as `ml_powered_queries_enabled` affect the produced alerts.
|
||||
// Considering these feature flags disabled in the event of a transient error could
|
||||
// therefore lead to alert churn. As a result, we crash if we cannot determine the value of
|
||||
// the feature flags.
|
||||
throw new Error(`Encountered an error while trying to load feature flags: ${e}`);
|
||||
if (e instanceof Error &&
|
||||
e.message.includes("Resource not accessible by integration")) {
|
||||
throw new Error(`Resource not accessible by integration. This usually means that your ` +
|
||||
`workflow is missing the required security-events write permissions. ` +
|
||||
`See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions ` +
|
||||
`for more information.`);
|
||||
}
|
||||
else {
|
||||
// Some feature flags, such as `ml_powered_queries_enabled` affect the produced alerts.
|
||||
// Considering these feature flags disabled in the event of a transient error could
|
||||
// therefore lead to alert churn. As a result, we crash if we cannot determine the value of
|
||||
// the feature flags.
|
||||
throw new Error(`Encountered an error while trying to load feature flags: ${e}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
const apiResponse = this.cachedApiResponse || (await loadApiResponse());
|
||||
|
||||
Reference in New Issue
Block a user