Skip to content

Commit a65575b

Browse files
committed
Use ConfigureationError for exceptions
1 parent f6d19ed commit a65575b

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-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

+4-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,14 @@ 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("Invalid credentials - must specify host or url");
6869
}
6970

7071
// Filter credentials based on language if specified. `type` is the registry type.
@@ -85,7 +86,7 @@ export function getCredentials(
8586
!isPrintable(e.password) ||
8687
!isPrintable(e.token)
8788
) {
88-
throw new Error(
89+
throw new ConfigurationError(
8990
"Invalid credentials - fields must contain only printable characters",
9091
);
9192
}

0 commit comments

Comments
 (0)