fix(backend): dbErr 503 degradation for connection-class DB errors
This commit is contained in:
@@ -24,7 +24,7 @@ func (a *api) getBookRow(c *gin.Context, id int64) (store.Book, bool) {
|
||||
err(c, http.StatusNotFound, "not_found", "no such book")
|
||||
return store.Book{}, false
|
||||
}
|
||||
err(c, http.StatusInternalServerError, "internal", "db error")
|
||||
dbErr(c, e)
|
||||
return store.Book{}, false
|
||||
}
|
||||
return b, true
|
||||
@@ -87,7 +87,7 @@ func (a *api) listBooks(c *gin.Context) {
|
||||
libID, _ := strconv.ParseInt(c.Query("library"), 10, 64)
|
||||
views, e := a.st.ListBooks(c, libID, c.Query("q"), c.Query("prefix"), uid(c))
|
||||
if e != nil {
|
||||
err(c, http.StatusInternalServerError, "internal", "db error")
|
||||
dbErr(c, e)
|
||||
return
|
||||
}
|
||||
out := make([]gin.H, 0, len(views))
|
||||
@@ -133,7 +133,7 @@ func (a *api) deleteBook(c *gin.Context) {
|
||||
os.RemoveAll(bookfile.CoverDir(a.cfg.CacheDir, key))
|
||||
os.RemoveAll(bookfile.PagesDir(a.cfg.CacheDir, key))
|
||||
if e := a.st.DeleteBook(c, b.ID); e != nil {
|
||||
err(c, http.StatusInternalServerError, "internal", "db error")
|
||||
dbErr(c, e)
|
||||
return
|
||||
}
|
||||
c.Status(http.StatusNoContent)
|
||||
|
||||
Reference in New Issue
Block a user