Skip to content

Commit c4b0f60

Browse files
committed
Remove superfluous error handling details
1 parent 5135700 commit c4b0f60

File tree

3 files changed

+11
-28
lines changed

3 files changed

+11
-28
lines changed

lib/start-proxy-action.js

Lines changed: 5 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/start-proxy/reachability.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ test("checkConnections - excludes failed status codes", async (t) => {
6060
sinon
6161
.stub(backend, "checkConnection")
6262
.onSecondCall()
63-
.throws(new ReachabilityError(nugetFeed, 400));
63+
.throws(new ReachabilityError(400));
6464
const messages = await withRecordingLoggerAsync(async (logger) => {
6565
const reachable = await checkConnections(logger, proxyInfo, backend);
6666
t.is(reachable.size, 1);

src/start-proxy/reachability.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,11 @@ import { HttpsProxyAgent } from "https-proxy-agent";
55
import { Logger } from "../logging";
66
import { getErrorMessage } from "../util";
77

8-
import { getAddressString, ProxyInfo, Registry, ValidRegistry } from "./types";
8+
import { getAddressString, ProxyInfo, ValidRegistry } from "./types";
99

1010
export class ReachabilityError extends Error {
11-
constructor(
12-
public readonly registry: Registry,
13-
public readonly statusCode?: number | undefined,
14-
) {
15-
const statusStr = ReachabilityError.getStatusStr(statusCode);
16-
super(`Connection test to ${registry.url} failed.${statusStr}`);
17-
}
18-
19-
private static getStatusStr(statusCode: number | undefined) {
20-
if (statusCode === undefined) return "";
21-
return ` (${statusCode})`;
11+
constructor(public readonly statusCode?: number | undefined) {
12+
super();
2213
}
2314
}
2415

@@ -63,13 +54,12 @@ class NetworkReachabilityBackend implements ReachabilityBackend {
6354
if (res.statusCode !== undefined && res.statusCode < 400) {
6455
resolve(res.statusCode);
6556
} else {
66-
reject(new ReachabilityError(registry, res.statusCode));
57+
reject(new ReachabilityError(res.statusCode));
6758
}
6859
},
6960
);
7061
req.on("error", (e) => {
71-
this.logger.error(e);
72-
reject(new ReachabilityError(registry));
62+
reject(e);
7363
});
7464
req.end();
7565
});

0 commit comments

Comments
 (0)