Skip to content

Commit 976aae7

Browse files
authored
fix(desktop): fix error handling by adding errorName function to identify NotFoundError rather than statusCode (#17591)
1 parent 0ca51ee commit 976aae7

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

packages/app/src/components/terminal.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,11 @@ const debugTerminal = (...values: unknown[]) => {
6565
console.debug("[terminal]", ...values)
6666
}
6767

68-
const errorStatus = (err: unknown) => {
68+
const errorName = (err: unknown) => {
6969
if (!err || typeof err !== "object") return
70-
if (!("data" in err)) return
71-
const data = err.data
72-
if (!data || typeof data !== "object") return
73-
if (!("statusCode" in data)) return
74-
const status = data.statusCode
75-
return typeof status === "number" ? status : undefined
70+
if (!("name" in err)) return
71+
const errorName = err.name
72+
return typeof errorName === "string" ? errorName : undefined
7673
}
7774

7875
const useTerminalUiBindings = (input: {
@@ -481,7 +478,7 @@ export const Terminal = (props: TerminalProps) => {
481478
.get({ ptyID: id })
482479
.then(() => false)
483480
.catch((err) => {
484-
if (errorStatus(err) === 404) return true
481+
if (errorName(err) === "NotFoundError") return true
485482
debugTerminal("failed to inspect terminal session", err)
486483
return false
487484
})

0 commit comments

Comments
 (0)