Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

Commit

Permalink
Add error logging (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgdigital committed Jun 13, 2023
1 parent 621b1b3 commit 57cab64
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ func main() {
log.Info("Loading SQLite DB...")
db, err := sqlitedb.Open(dbPath)
if err != nil {
log.WithField("error", err).Error("Failed to open database")
panic(err)
}
log.Info("Loading trackers file...")
trackers, err := magnet.GetTrackers(trackersPath)
if err != nil {
log.WithField("error", err).Error("Failed to open trackers file")
panic(err)
}
http.HandleFunc("/torznab/", torznab.CreateHandler(db, trackers))
Expand Down
1 change: 1 addition & 0 deletions torznab/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func CreateHandler(db *sql.DB, trackers []string) func(http.ResponseWriter, *htt
}
result, err := Search(db, trackers, searchQuery)
if err != nil {
log.WithField("error", err).Error("Failed to handle request")
w.WriteHeader(http.StatusInternalServerError)
_, err = io.WriteString(w, "internal server error")
return
Expand Down

0 comments on commit 57cab64

Please sign in to comment.