Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5cc268e

Browse files
committedJun 7, 2024··
Improve error message for failed build watch
1 parent a463da7 commit 5cc268e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed
 

‎src/remote.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import * as semver from "semver"
1212
import * as vscode from "vscode"
1313
import * as ws from "ws"
1414
import { makeCoderSdk } from "./api"
15+
import { errToStr } from "./api-helper"
1516
import { Commands } from "./commands"
1617
import { getHeaderCommand } from "./headers"
1718
import { SSHConfig, SSHValues, mergeSSHConfigValues } from "./sshConfig"
@@ -238,7 +239,8 @@ export class Remote {
238239
try {
239240
const baseUrl = new URL(baseUrlRaw)
240241
const proto = baseUrl.protocol === "https:" ? "wss:" : "ws:"
241-
const socket = new ws.WebSocket(new URL(`${proto}//${baseUrl.host}${path}`), {
242+
const socketUrlRaw = `${proto}//${baseUrl.host}${path}`
243+
const socket = new ws.WebSocket(new URL(socketUrlRaw), {
242244
headers: {
243245
"Coder-Session-Token": token,
244246
},
@@ -249,15 +251,15 @@ export class Remote {
249251
const log = JSON.parse(buf.toString()) as ProvisionerJobLog
250252
writeEmitter.fire(log.output + "\r\n")
251253
})
252-
socket.on("error", (err) => {
253-
reject(err)
254+
socket.on("error", (error) => {
255+
reject(new Error(`Failed to open web socket to ${socketUrlRaw}: ${errToStr(error, "no further details")}`))
254256
})
255257
socket.on("close", () => {
256258
resolve()
257259
})
258260
} catch (error) {
259261
// If this errors, it is probably a malformed URL.
260-
reject(error)
262+
reject(new Error(`Failed to open web socket to ${baseUrlRaw}: ${errToStr(error, "no further details")}`))
261263
}
262264
})
263265
writeEmitter.fire("Build complete")

0 commit comments

Comments
 (0)
Please sign in to comment.