Only log error, don't exit

This commit is contained in:
ekzyis 2024-09-08 20:43:21 +02:00
parent 1b0c87f813
commit 8b1ad852f2
1 changed files with 4 additions and 2 deletions

6
db.go
View File

@ -42,7 +42,9 @@ func ItemHasComment(parentId int) bool {
err := db.QueryRow(`SELECT COUNT(1) FROM comments WHERE parent_id = ?`, parentId).Scan(&count)
if err != nil {
err = fmt.Errorf("error during item check: %w", err)
log.Fatal(err)
log.Println(err)
// pretend that item has comment to avoid duplicate comments
return true
}
return count > 0
}
@ -51,6 +53,6 @@ func SaveComment(comment *sn.Comment) {
_, err := db.Exec(`INSERT INTO comments(id, text, parent_id) VALUES (?, ?, ?)`, comment.Id, comment.Text, comment.ParentId)
if err != nil {
err = fmt.Errorf("error during item insert: %w", err)
log.Fatal(err)
log.Println(err)
}
}