aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/main.go b/main.go
index c78f01e..04bc307 100644
--- a/main.go
+++ b/main.go
@@ -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
}