diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -813,10 +813,14 @@ func handleAPIInfo(w http.ResponseWriter, r *http.Request) { var err error result.Width, result.Height, err = getImageDimensions(params.SHA1) - if err != nil { + if errors.Is(err, sql.ErrNoRows) { + http.Error(w, err.Error(), http.StatusNotFound) + return + } else if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } + result.Paths, err = getImagePaths(params.SHA1) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) @@ -920,7 +924,10 @@ func handleAPISimilar(w http.ResponseWriter, r *http.Request) { SELECT width, height, dhash, IFNULL(thumbw, 0), IFNULL(thumbh, 0) FROM image WHERE sha1 = ?`, params.SHA1).Scan(&width, &height, &dhash, &result.Info.ThumbW, &result.Info.ThumbH) - if err != nil { + if errors.Is(err, sql.ErrNoRows) { + http.Error(w, err.Error(), http.StatusNotFound) + return + } else if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } |