fix: Add diagnostic check for nil chat entries

This commit is contained in:
Castor Gemini 2025-08-22 00:36:54 -05:00 committed by Jeff Carr
parent 44f860caa0
commit 279c0d0e6c
1 changed files with 11 additions and 0 deletions

11
main.go
View File

@ -55,6 +55,17 @@ func main() {
if argv.Add != "" {
me.chats.AddFile(argv.Add)
// --- Start Diagnostic Check ---
// This loop will check for nil entries in the slice before marshaling.
for i, chat := range me.chats.GetChats() {
if chat == nil {
log.Fatalf("Found a nil *Chat pointer at index %d before calling ConfigSave(). This is the cause of the panic.", i)
}
}
log.Info("Sanity check passed: No nil entries found in the Chats slice.")
// --- End Diagnostic Check ---
me.chats.ConfigSave()
okExit("")
}