Use ConfigureationError for exceptions
This commit is contained in:
parent
f6d19ed42e
commit
7c2eafa990
3 changed files with 11 additions and 7 deletions
7
lib/start-proxy.js
generated
7
lib/start-proxy.js
generated
|
|
@ -2,6 +2,7 @@
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getCredentials = getCredentials;
|
||||
const languages_1 = require("./languages");
|
||||
const util_1 = require("./util");
|
||||
const LANGUAGE_TO_REGISTRY_TYPE = {
|
||||
java: "maven_repository",
|
||||
csharp: "nuget_feed",
|
||||
|
|
@ -44,13 +45,13 @@ function getCredentials(logger, registrySecrets, registriesCredentials, language
|
|||
catch {
|
||||
// Don't log the error since it might contain sensitive information.
|
||||
logger.error("Failed to parse the credentials data.");
|
||||
throw new Error("Invalid credentials format.");
|
||||
throw new util_1.ConfigurationError("Invalid credentials format.");
|
||||
}
|
||||
const out = [];
|
||||
for (const e of parsed) {
|
||||
if (e.url === undefined && e.host === undefined) {
|
||||
// The proxy needs one of these to work. If both are defined, the url has the precedence.
|
||||
throw new Error("Invalid credentials - must specify host or url");
|
||||
throw new util_1.ConfigurationError("Invalid credentials - must specify host or url");
|
||||
}
|
||||
// Filter credentials based on language if specified. `type` is the registry type.
|
||||
// E.g., "maven_feed" for Java/Kotlin, "nuget_repository" for C#.
|
||||
|
|
@ -66,7 +67,7 @@ function getCredentials(logger, registrySecrets, registriesCredentials, language
|
|||
!isPrintable(e.username) ||
|
||||
!isPrintable(e.password) ||
|
||||
!isPrintable(e.token)) {
|
||||
throw new Error("Invalid credentials - fields must contain only printable characters");
|
||||
throw new util_1.ConfigurationError("Invalid credentials - fields must contain only printable characters");
|
||||
}
|
||||
out.push({
|
||||
type: e.type,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue