diff --git a/lib/analyze-action.js b/lib/analyze-action.js index 0afac73f9..253ef2c9b 100644 --- a/lib/analyze-action.js +++ b/lib/analyze-action.js @@ -83628,6 +83628,9 @@ function isEnablementError(msg) { /Code Scanning is not enabled/ ].some((pattern) => pattern.test(msg)); } +function getFeatureEnablementError(message) { + return `Please verify that the necessary features are enabled: ${message}`; +} function wrapApiConfigurationError(e) { const httpError = asHTTPError(e); if (httpError !== void 0) { @@ -83646,7 +83649,7 @@ function wrapApiConfigurationError(e) { } if (isEnablementError(httpError.message)) { return new ConfigurationError( - `Please verify that the necessary features are enabled: ${httpError.message}` + getFeatureEnablementError(httpError.message) ); } if (httpError.status === 429) { diff --git a/lib/init-action-post.js b/lib/init-action-post.js index df8b107c8..1f56d4943 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -116765,6 +116765,9 @@ function isEnablementError(msg) { /Code Scanning is not enabled/ ].some((pattern) => pattern.test(msg)); } +function getFeatureEnablementError(message) { + return `Please verify that the necessary features are enabled: ${message}`; +} function wrapApiConfigurationError(e) { const httpError = asHTTPError(e); if (httpError !== void 0) { @@ -116783,7 +116786,7 @@ function wrapApiConfigurationError(e) { } if (isEnablementError(httpError.message)) { return new ConfigurationError( - `Please verify that the necessary features are enabled: ${httpError.message}` + getFeatureEnablementError(httpError.message) ); } if (httpError.status === 429) { diff --git a/lib/init-action.js b/lib/init-action.js index 416315e82..3c63f5a42 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -80933,6 +80933,9 @@ function isEnablementError(msg) { /Code Scanning is not enabled/ ].some((pattern) => pattern.test(msg)); } +function getFeatureEnablementError(message) { + return `Please verify that the necessary features are enabled: ${message}`; +} function wrapApiConfigurationError(e) { const httpError = asHTTPError(e); if (httpError !== void 0) { @@ -80951,7 +80954,7 @@ function wrapApiConfigurationError(e) { } if (isEnablementError(httpError.message)) { return new ConfigurationError( - `Please verify that the necessary features are enabled: ${httpError.message}` + getFeatureEnablementError(httpError.message) ); } if (httpError.status === 429) { diff --git a/lib/setup-codeql-action.js b/lib/setup-codeql-action.js index 249d5bfc7..5b8888d45 100644 --- a/lib/setup-codeql-action.js +++ b/lib/setup-codeql-action.js @@ -79282,6 +79282,9 @@ function isEnablementError(msg) { /Code Scanning is not enabled/ ].some((pattern) => pattern.test(msg)); } +function getFeatureEnablementError(message) { + return `Please verify that the necessary features are enabled: ${message}`; +} function wrapApiConfigurationError(e) { const httpError = asHTTPError(e); if (httpError !== void 0) { @@ -79300,7 +79303,7 @@ function wrapApiConfigurationError(e) { } if (isEnablementError(httpError.message)) { return new ConfigurationError( - `Please verify that the necessary features are enabled: ${httpError.message}` + getFeatureEnablementError(httpError.message) ); } if (httpError.status === 429) { diff --git a/lib/upload-lib.js b/lib/upload-lib.js index 68e449efa..d220cda56 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -82153,6 +82153,9 @@ function isEnablementError(msg) { /Code Scanning is not enabled/ ].some((pattern) => pattern.test(msg)); } +function getFeatureEnablementError(message) { + return `Please verify that the necessary features are enabled: ${message}`; +} function wrapApiConfigurationError(e) { const httpError = asHTTPError(e); if (httpError !== void 0) { @@ -82171,7 +82174,7 @@ function wrapApiConfigurationError(e) { } if (isEnablementError(httpError.message)) { return new ConfigurationError( - `Please verify that the necessary features are enabled: ${httpError.message}` + getFeatureEnablementError(httpError.message) ); } if (httpError.status === 429) { diff --git a/lib/upload-sarif-action.js b/lib/upload-sarif-action.js index cb5dd92dc..1a981457f 100644 --- a/lib/upload-sarif-action.js +++ b/lib/upload-sarif-action.js @@ -82198,6 +82198,9 @@ function isEnablementError(msg) { /Code Scanning is not enabled/ ].some((pattern) => pattern.test(msg)); } +function getFeatureEnablementError(message) { + return `Please verify that the necessary features are enabled: ${message}`; +} function wrapApiConfigurationError(e) { const httpError = asHTTPError(e); if (httpError !== void 0) { @@ -82216,7 +82219,7 @@ function wrapApiConfigurationError(e) { } if (isEnablementError(httpError.message)) { return new ConfigurationError( - `Please verify that the necessary features are enabled: ${httpError.message}` + getFeatureEnablementError(httpError.message) ); } if (httpError.status === 429) { diff --git a/src/api-client.test.ts b/src/api-client.test.ts index 301eb91a1..29e3ef852 100644 --- a/src/api-client.test.ts +++ b/src/api-client.test.ts @@ -179,7 +179,7 @@ test("wrapApiConfigurationError correctly wraps specific configuration errors", t.deepEqual( res, new util.ConfigurationError( - `Please verify that the necessary features are enabled: ${codeSecurityNotEnabledError.message}`, + api.getFeatureEnablementError(codeSecurityNotEnabledError.message), ), ); const advancedSecurityNotEnabledError = new util.HTTPError( @@ -190,7 +190,7 @@ test("wrapApiConfigurationError correctly wraps specific configuration errors", t.deepEqual( res, new util.ConfigurationError( - `Please verify that the necessary features are enabled: ${advancedSecurityNotEnabledError.message}`, + api.getFeatureEnablementError(advancedSecurityNotEnabledError.message), ), ); const codeScanningNotEnabledError = new util.HTTPError( @@ -201,7 +201,7 @@ test("wrapApiConfigurationError correctly wraps specific configuration errors", t.deepEqual( res, new util.ConfigurationError( - `Please verify that the necessary features are enabled: ${codeScanningNotEnabledError.message}`, + api.getFeatureEnablementError(codeScanningNotEnabledError.message), ), ); }); diff --git a/src/api-client.ts b/src/api-client.ts index e947672c6..8b730e4ed 100644 --- a/src/api-client.ts +++ b/src/api-client.ts @@ -291,6 +291,12 @@ function isEnablementError(msg: string) { ].some((pattern) => pattern.test(msg)); } +// TODO: Move to `error-messages.ts` after refactoring import order to avoid cycle +// since `error-messages.ts` currently depends on this file. +export function getFeatureEnablementError(message: string): string { + return `Please verify that the necessary features are enabled: ${message}`; +} + export function wrapApiConfigurationError(e: unknown) { const httpError = asHTTPError(e); if (httpError !== undefined) { @@ -314,7 +320,7 @@ export function wrapApiConfigurationError(e: unknown) { } if (isEnablementError(httpError.message)) { return new ConfigurationError( - `Please verify that the necessary features are enabled: ${httpError.message}`, + getFeatureEnablementError(httpError.message), ); } if (httpError.status === 429) {