Error handling for the /rest/uploads endpoint

This commit is contained in:
Justin Hawkins 2021-10-11 22:50:10 +10:30
parent 2c4c9fdde6
commit f180900d79

View File

@ -152,7 +152,13 @@ func (ws *WebService) handleConfig(w http.ResponseWriter, r *http.Request) {
func (ws *WebService) getUploads(w http.ResponseWriter, r *http.Request) { func (ws *WebService) getUploads(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
ups := ws.Uploader.Uploads ups := ws.Uploader.Uploads
text, _ := json.Marshal(ups)
text, err := json.Marshal(ups)
if err != nil {
daulog.SendLog(fmt.Sprintf("err: %v", err), daulog.LogTypeError)
w.Write([]byte("could not marshall uploads?"))
return
}
w.Write([]byte(text)) w.Write([]byte(text))
} }