mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-22 16:44:36 +00:00
fix(desktop): fix error handling by adding errorName function to identify NotFoundError rather than statusCode (#17591)
This commit is contained in:
@@ -65,14 +65,11 @@ const debugTerminal = (...values: unknown[]) => {
|
|||||||
console.debug("[terminal]", ...values)
|
console.debug("[terminal]", ...values)
|
||||||
}
|
}
|
||||||
|
|
||||||
const errorStatus = (err: unknown) => {
|
const errorName = (err: unknown) => {
|
||||||
if (!err || typeof err !== "object") return
|
if (!err || typeof err !== "object") return
|
||||||
if (!("data" in err)) return
|
if (!("name" in err)) return
|
||||||
const data = err.data
|
const errorName = err.name
|
||||||
if (!data || typeof data !== "object") return
|
return typeof errorName === "string" ? errorName : undefined
|
||||||
if (!("statusCode" in data)) return
|
|
||||||
const status = data.statusCode
|
|
||||||
return typeof status === "number" ? status : undefined
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const useTerminalUiBindings = (input: {
|
const useTerminalUiBindings = (input: {
|
||||||
@@ -481,7 +478,7 @@ export const Terminal = (props: TerminalProps) => {
|
|||||||
.get({ ptyID: id })
|
.get({ ptyID: id })
|
||||||
.then(() => false)
|
.then(() => false)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
if (errorStatus(err) === 404) return true
|
if (errorName(err) === "NotFoundError") return true
|
||||||
debugTerminal("failed to inspect terminal session", err)
|
debugTerminal("failed to inspect terminal session", err)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user