mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-08 18:16:59 +00:00
Don't return 500s from media API download requests
This commit is contained in:
parent
d6e18a33ce
commit
4fd97df2c5
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user