mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-11 03:13:24 +00:00
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:
1 parent
3f24337256
commit
bcd23c587b
3 files changed
+18
-3
No files matched your search
@@ -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.
|
||||
|
||||
@@ -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)")
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user