Skip to content

The open source coding agent.

TypeScript

fix(desktop): fix error handling by adding errorName function to identify NotFoundError rather than statusCode (#17591)

OpeOginni976aae7e4227
diff --git a/packages/app/src/components/terminal.tsx b/packages/app/src/components/terminal.tsx
index d4eccbc828c..9297d66266e 100644
--- a/packages/app/src/components/terminal.tsx
+++ b/packages/app/src/components/terminal.tsx
@@ -65,14 +65,11 @@ const debugTerminal = (...values: unknown[]) => {
console.debug("[terminal]", ...values)
}
-const errorStatus = (err: unknown) => {
+const errorName = (err: unknown) => {
if (!err || typeof err !== "object") return
- if (!("data" in err)) return
- const data = err.data
- if (!data || typeof data !== "object") return
- if (!("statusCode" in data)) return
- const status = data.statusCode
- return typeof status === "number" ? status : undefined
+ if (!("name" in err)) return
+ const errorName = err.name
+ return typeof errorName === "string" ? errorName : undefined
}
const useTerminalUiBindings = (input: {
@@ -481,7 +478,7 @@ export const Terminal = (props: TerminalProps) => {
.get({ ptyID: id })
.then(() => false)
.catch((err) => {
- if (errorStatus(err) === 404) return true
+ if (errorName(err) === "NotFoundError") return true
debugTerminal("failed to inspect terminal session", err)
return false
})