Improve error categorizations
This commit is contained in:
parent
db40ac46b9
commit
1d367b0bec
24 changed files with 47 additions and 38 deletions
10
lib/util.js
generated
10
lib/util.js
generated
|
|
@ -78,7 +78,7 @@ function getExtraOptionsEnvParam() {
|
|||
}
|
||||
catch (unwrappedError) {
|
||||
const error = wrapError(unwrappedError);
|
||||
throw new Error(`${varName} environment variable is set, but does not contain valid JSON: ${error.message}`);
|
||||
throw new UserError(`${varName} environment variable is set, but does not contain valid JSON: ${error.message}`);
|
||||
}
|
||||
}
|
||||
exports.getExtraOptionsEnvParam = getExtraOptionsEnvParam;
|
||||
|
|
@ -142,7 +142,7 @@ function getMemoryFlagValueForPlatform(userInput, totalMemoryBytes, platform) {
|
|||
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 {
|
||||
|
|
@ -251,7 +251,7 @@ function getThreadsFlagValue(userInput, logger) {
|
|||
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(`Clamping desired number of threads (${numThreads}) to max available (${maxThreads}).`);
|
||||
|
|
@ -299,14 +299,14 @@ function parseGitHubUrl(inputUrl) {
|
|||
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;
|
||||
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
|
||||
// then return with a fixed canonical URL.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue