fix: hide errors from public view, put into logs

This commit is contained in:
Lukas Werner 2025-12-01 12:25:12 -08:00
parent c1e8556582
commit 97bbafe827
No known key found for this signature in database

View File

@ -2,6 +2,7 @@ package handlers
import ( import (
"encoding/json" "encoding/json"
"log"
"net/http" "net/http"
"time" "time"
@ -20,7 +21,7 @@ func ListFiles(client valkey.Client) http.HandlerFunc {
expiresInt, err := client.Do(r.Context(), client.B().Ttl().Key(upload_id).Build()).AsInt64() expiresInt, err := client.Do(r.Context(), client.B().Ttl().Key(upload_id).Build()).AsInt64()
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusNotFound) http.Error(w, "not found", http.StatusNotFound)
return return
} }
expiresIn := time.Second * time.Duration(expiresInt) expiresIn := time.Second * time.Duration(expiresInt)
@ -29,7 +30,8 @@ func ListFiles(client valkey.Client) http.HandlerFunc {
files_json, err := client.Do(r.Context(), files_json, err := client.Do(r.Context(),
client.B().Get().Key(upload_id).Build()).ToString() client.B().Get().Key(upload_id).Build()).ToString()
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusNotFound) log.Printf("upload_id:'%s' err: %s\n", upload_id, err.Error())
http.Error(w, "not found", http.StatusNotFound)
return return
} }
@ -37,7 +39,8 @@ func ListFiles(client valkey.Client) http.HandlerFunc {
err = json.Unmarshal([]byte(files_json), &fileIds) err = json.Unmarshal([]byte(files_json), &fileIds)
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) log.Printf("upload_id:'%s' err: %s\n", upload_id, err.Error())
http.Error(w, "not found", http.StatusInternalServerError)
return return
} }