diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2020-05-11 11:01:24 +0100 |
---|---|---|
committer | Neil Alexander <neilalexander@users.noreply.github.com> | 2020-05-11 14:01:07 +0100 |
commit | 4fd97df2c5ac86bf908432d29259bdda5912b89b (patch) | |
tree | bc81497fbe0b81699ae1268bcaaea8b69febeb7c /mediaapi | |
parent | d6e18a33ce1dd85c922165b89aaf680fd5de8535 (diff) |
Don't return 500s from media API download requests
Diffstat (limited to 'mediaapi')
-rw-r--r-- | mediaapi/routing/download.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/mediaapi/routing/download.go b/mediaapi/routing/download.go index 8544bd64..9feca90e 100644 --- a/mediaapi/routing/download.go +++ b/mediaapi/routing/download.go @@ -118,7 +118,10 @@ func Download( ) if err != nil { // TODO: Handle the fact we might have started writing the response - dReq.jsonErrorResponse(w, util.ErrorResponse(err)) + dReq.jsonErrorResponse(w, util.JSONResponse{ + Code: http.StatusNotFound, + JSON: jsonerror.NotFound("Failed to download: " + err.Error()), + }) return } @@ -138,7 +141,7 @@ func (r *downloadRequest) jsonErrorResponse(w http.ResponseWriter, res util.JSON if err != nil { r.Logger.WithError(err).Error("Failed to marshal JSONResponse") // this should never fail to be marshalled so drop err to the floor - res = util.MessageResponse(http.StatusInternalServerError, "Internal Server Error") + res = util.MessageResponse(http.StatusNotFound, "Download request failed: "+err.Error()) resBytes, _ = json.Marshal(res.JSON) } |