fix: handle input and database read errors in client and doctor commands (#1480)

Added error handling for input reading in the agent chat client and for database row reading in the doctor commands, ensuring that errors are reported clearly to the user.
This commit is contained in:
Leo225 authored and GitHub committed 2026-07-31 18:30:28 +07:00
1 parent 3f24337256
commit bcd23c587b
3 files changed
+18 -3

No files matched your search

+4
View File
@@ -76,6 +76,10 @@ func runClientMode(cfg *config.Config, addr, agentName, message, sessionKey stri
}
fmt.Printf("\n%s\n\n", resp)
}
if err := scanner.Err(); err != nil {
fmt.Fprintf(os.Stderr, "Input error: %v\n", err)
os.Exit(1)
}
}
// wsConnect sends the connect RPC and waits for auth response.
+8
View File
@@ -187,6 +187,10 @@ func checkDBChannels(db *sql.DB) {
label := fmt.Sprintf("%s/%s", channelType, name)
fmt.Printf(" %-24s %s\n", label+":", status)
}
if err := rows.Err(); err != nil {
fmt.Printf(" (could not read channels: %s)\n", err)
return
}
if !found {
fmt.Println(" (none configured in database)")
}
@@ -218,6 +222,10 @@ func checkDBProviders(db *sql.DB) {
}
fmt.Printf(" %-16s %s\n", displayName+":", status)
}
if err := rows.Err(); err != nil {
fmt.Printf(" (could not read providers: %s)\n", err)
return
}
if !found {
fmt.Println(" (none configured in database)")
}
+6 -3
View File
@@ -14,11 +14,14 @@ func buildMergedSubagentAnnounce(entries []subagentAnnounceEntry, roster tools.S
if len(entries) == 1 {
e := entries[0]
statusLabel := "completed successfully"
if e.Status == "failed" {
var statusLabel string
switch e.Status {
case "failed":
statusLabel = "failed"
} else if e.Status == "cancelled" {
case "cancelled":
statusLabel = "was cancelled"
default:
statusLabel = "completed successfully"
}
fmt.Fprintf(&sb, "[System Message] A subagent task %q just %s.\n\nResult:\n%s\n\nStats: runtime %s, iterations %d, tokens %d in / %d out\n",
e.Label, statusLabel, e.Content,