Skip to content

Commit 5f03ca3

Browse files
committed
Rename SelfSignedCertificateError to CertificateError
This class will handle various certificate errors.
1 parent 19d6bbe commit 5f03ca3

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

src/commands.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { getAuthenticatedUser, getWorkspaces, updateWorkspaceVersion } from "cod
33
import { Workspace, WorkspaceAgent } from "coder/site/src/api/typesGenerated"
44
import * as vscode from "vscode"
55
import { extractAgents } from "./api-helper"
6-
import { SelfSignedCertificateError } from "./error"
6+
import { CertificateError } from "./error"
77
import { Remote } from "./remote"
88
import { Storage } from "./storage"
99
import { OpenableTreeItem } from "./workspacesProvider"
@@ -62,8 +62,8 @@ export class Commands {
6262
if (axios.isAxiosError(err) && err.response?.data) {
6363
message = err.response.data.detail
6464
}
65-
if (err instanceof SelfSignedCertificateError) {
66-
err.showInsecureNotification()
65+
if (err instanceof CertificateError) {
66+
err.showNotification()
6767

6868
return {
6969
message: err.message,
@@ -199,8 +199,8 @@ export class Commands {
199199
quickPick.busy = false
200200
})
201201
.catch((ex) => {
202-
if (ex instanceof SelfSignedCertificateError) {
203-
ex.showInsecureNotification()
202+
if (ex instanceof CertificateError) {
203+
ex.showNotification()
204204
}
205205
return
206206
})

src/error.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as vscode from "vscode"
22

3-
export class SelfSignedCertificateError extends Error {
3+
export class CertificateError extends Error {
44
public static Notification =
55
"Your Coder deployment is using a self-signed certificate. VS Code uses a version of Electron that does not support registering self-signed intermediate certificates with extensions."
66
public static ActionAllowInsecure = "Allow Insecure"
@@ -20,17 +20,17 @@ export class SelfSignedCertificateError extends Error {
2020
vscode.window.showInformationMessage(CertificateError.InsecureMessage)
2121
}
2222

23-
public async showInsecureNotification(): Promise<void> {
23+
public async showNotification(): Promise<void> {
2424
const value = await vscode.window.showErrorMessage(
25-
SelfSignedCertificateError.Notification,
26-
SelfSignedCertificateError.ActionAllowInsecure,
27-
SelfSignedCertificateError.ActionViewMoreDetails,
25+
CertificateError.Notification,
26+
CertificateError.ActionAllowInsecure,
27+
CertificateError.ActionViewMoreDetails,
2828
)
29-
if (value === SelfSignedCertificateError.ActionViewMoreDetails) {
29+
if (value === CertificateError.ActionViewMoreDetails) {
3030
await this.viewMoreDetails()
3131
return
3232
}
33-
if (value === SelfSignedCertificateError.ActionAllowInsecure) {
33+
if (value === CertificateError.ActionAllowInsecure) {
3434
return this.allowInsecure()
3535
}
3636
}

src/extension.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as https from "https"
55
import * as module from "module"
66
import * as vscode from "vscode"
77
import { Commands } from "./commands"
8-
import { SelfSignedCertificateError } from "./error"
8+
import { CertificateError } from "./error"
99
import { Remote } from "./remote"
1010
import { Storage } from "./storage"
1111
import { WorkspaceQuery, WorkspaceProvider } from "./workspacesProvider"
@@ -49,7 +49,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
4949
if (err) {
5050
const msg = err.toString() as string
5151
if (msg.indexOf("unable to verify the first certificate") !== -1) {
52-
throw new SelfSignedCertificateError(msg)
52+
throw new CertificateError(msg)
5353
}
5454
}
5555

@@ -144,23 +144,23 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
144144
try {
145145
await remote.setup(vscodeProposed.env.remoteAuthority)
146146
} catch (ex) {
147-
if (ex instanceof SelfSignedCertificateError) {
147+
if (ex instanceof CertificateError) {
148148
const prompt = await vscodeProposed.window.showErrorMessage(
149149
"Failed to open workspace",
150150
{
151-
detail: SelfSignedCertificateError.Notification,
151+
detail: CertificateError.Notification,
152152
modal: true,
153153
useCustom: true,
154154
},
155-
SelfSignedCertificateError.ActionAllowInsecure,
156-
SelfSignedCertificateError.ActionViewMoreDetails,
155+
CertificateError.ActionAllowInsecure,
156+
CertificateError.ActionViewMoreDetails,
157157
)
158-
if (prompt === SelfSignedCertificateError.ActionAllowInsecure) {
158+
if (prompt === CertificateError.ActionAllowInsecure) {
159159
await ex.allowInsecure(storage)
160160
await remote.reloadWindow()
161161
return
162162
}
163-
if (prompt === SelfSignedCertificateError.ActionViewMoreDetails) {
163+
if (prompt === CertificateError.ActionViewMoreDetails) {
164164
await ex.viewMoreDetails()
165165
return
166166
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy