fix(tui): show bootstrap errors instead of {} to trace (#4779)

Co-authored-by: Github Action <action@github.com>
This commit is contained in:
Jensen
2025-11-27 00:49:55 +08:00
committed by GitHub
parent 8963b536ee
commit 33f004d4b6
3 changed files with 26 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
import { useRenderer } from "@opentui/solid"
import { createSimpleContext } from "./helper"
import { FormatError } from "@/cli/error"
import { FormatError, FormatUnknownError } from "@/cli/error"
export const { use: useExit, provider: ExitProvider } = createSimpleContext({
name: "Exit",
@@ -10,8 +10,10 @@ export const { use: useExit, provider: ExitProvider } = createSimpleContext({
renderer.destroy()
await input.onExit?.()
if (reason) {
const formatted = FormatError(reason) ?? JSON.stringify(reason)
process.stderr.write(formatted + "\n")
const formatted = FormatError(reason) ?? FormatUnknownError(reason)
if (formatted) {
process.stderr.write(formatted + "\n")
}
}
process.exit(0)
}

View File

@@ -23,6 +23,7 @@ import { createSimpleContext } from "./helper"
import type { Snapshot } from "@/snapshot"
import { useExit } from "./exit"
import { batch, onMount } from "solid-js"
import { Log } from "@/util/log"
export const { use: useSync, provider: SyncProvider } = createSimpleContext({
name: "Sync",
@@ -290,6 +291,11 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
})
})
.catch(async (e) => {
Log.Default.error("tui bootstrap failed", {
error: e instanceof Error ? e.message : String(e),
name: e instanceof Error ? e.name : undefined,
stack: e instanceof Error ? e.stack : undefined,
})
await exit(e)
})
}