diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -34,15 +34,29 @@ func main() { } log.Printf("Storage directory: %s\n", storage.Path) - db := model.OpenDB(filepath.Join(storage.Path, "ceres.sqlite3")) - defer db.Close() - err := db.Migrate() + db, err := model.OpenDB(filepath.Join(storage.Path, "ceres.sqlite3")) + if err != nil { + log.Fatalf("Failed to open database: %v", err) + } + defer func() { + err := db.Close() + if err != nil { + log.Println("Failed to close database") + } else { + log.Println("Closed database") + } + }() + + err = db.Migrate() if err != nil { log.Fatal(err) } if flags.examples { - db.CreateExamples() + err := db.CreateExamples() + if err != nil { + log.Fatalf("Failed to insert example recipes: %v", err) + } log.Println("Created example recipes") } |