Skip to content

Commit 7c2eafa

Browse files
committed
Use ConfigureationError for exceptions
1 parent f6d19ed commit 7c2eafa

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

lib/start-proxy.js

+4-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/start-proxy.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/start-proxy.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { parseLanguage, Language } from "./languages";
22
import { Logger } from "./logging";
3+
import { ConfigurationError } from "./util";
34

45
export type Credential = {
56
type: string;
@@ -57,14 +58,16 @@ export function getCredentials(
5758
} catch {
5859
// Don't log the error since it might contain sensitive information.
5960
logger.error("Failed to parse the credentials data.");
60-
throw new Error("Invalid credentials format.");
61+
throw new ConfigurationError("Invalid credentials format.");
6162
}
6263

6364
const out: Credential[] = [];
6465
for (const e of parsed) {
6566
if (e.url === undefined && e.host === undefined) {
6667
// The proxy needs one of these to work. If both are defined, the url has the precedence.
67-
throw new Error("Invalid credentials - must specify host or url");
68+
throw new ConfigurationError(
69+
"Invalid credentials - must specify host or url",
70+
);
6871
}
6972

7073
// Filter credentials based on language if specified. `type` is the registry type.
@@ -85,7 +88,7 @@ export function getCredentials(
8588
!isPrintable(e.password) ||
8689
!isPrintable(e.token)
8790
) {
88-
throw new Error(
91+
throw new ConfigurationError(
8992
"Invalid credentials - fields must contain only printable characters",
9093
);
9194
}

0 commit comments

Comments
 (0)