mirror of
https://github.com/github/codeql-action.git
synced 2026-01-04 21:50:17 +08:00
Improve error categorizations
This commit is contained in:
10
src/util.ts
10
src/util.ts
@@ -120,7 +120,7 @@ export function getExtraOptionsEnvParam(): object {
|
||||
return JSON.parse(raw);
|
||||
} catch (unwrappedError) {
|
||||
const error = wrapError(unwrappedError);
|
||||
throw new Error(
|
||||
throw new UserError(
|
||||
`${varName} environment variable is set, but does not contain valid JSON: ${error.message}`,
|
||||
);
|
||||
}
|
||||
@@ -204,7 +204,7 @@ export function getMemoryFlagValueForPlatform(
|
||||
if (userInput) {
|
||||
memoryToUseMegaBytes = Number(userInput);
|
||||
if (Number.isNaN(memoryToUseMegaBytes) || memoryToUseMegaBytes <= 0) {
|
||||
throw new Error(`Invalid RAM setting "${userInput}", specified.`);
|
||||
throw new UserError(`Invalid RAM setting "${userInput}", specified.`);
|
||||
}
|
||||
} else {
|
||||
const totalMemoryMegaBytes = totalMemoryBytes / (1024 * 1024);
|
||||
@@ -358,7 +358,7 @@ export function getThreadsFlagValue(
|
||||
if (userInput) {
|
||||
numThreads = Number(userInput);
|
||||
if (Number.isNaN(numThreads)) {
|
||||
throw new Error(`Invalid threads setting "${userInput}", specified.`);
|
||||
throw new UserError(`Invalid threads setting "${userInput}", specified.`);
|
||||
}
|
||||
if (numThreads > maxThreads) {
|
||||
logger.info(
|
||||
@@ -412,14 +412,14 @@ export function parseGitHubUrl(inputUrl: string): string {
|
||||
inputUrl = `https://${inputUrl}`;
|
||||
}
|
||||
if (!inputUrl.startsWith("http://") && !inputUrl.startsWith("https://")) {
|
||||
throw new Error(`"${originalUrl}" is not a http or https URL`);
|
||||
throw new UserError(`"${originalUrl}" is not a http or https URL`);
|
||||
}
|
||||
|
||||
let url: URL;
|
||||
try {
|
||||
url = new URL(inputUrl);
|
||||
} catch (e) {
|
||||
throw new Error(`"${originalUrl}" is not a valid URL`);
|
||||
throw new UserError(`"${originalUrl}" is not a valid URL`);
|
||||
}
|
||||
|
||||
// If we detect this is trying to be to github.com
|
||||
|
||||
Reference in New Issue
Block a user