Swap out a couple more internal server errors

This commit is contained in:
Neil Alexander 2020-04-16 15:27:38 +01:00
parent e55bc08c92
commit edecddcb29
2 changed files with 12 additions and 4 deletions

View file

@ -73,7 +73,10 @@ func Backfill(
}
if req.Limit, err = strconv.Atoi(limit); err != nil {
util.GetLogger(httpReq.Context()).WithError(err).Error("strconv.Atoi failed")
return jsonerror.InternalServerError()
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.InvalidArgumentValue("limit is invalid format"),
}
}
// Query the roomserver.

View file

@ -46,12 +46,17 @@ func GetProfile(
_, domain, err := gomatrixserverlib.SplitID('@', userID)
if err != nil {
util.GetLogger(httpReq.Context()).WithError(err).Error("gomatrixserverlib.SplitID failed")
return jsonerror.InternalServerError()
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.MissingArgument("Format of user ID is invalid."),
}
}
if domain != cfg.Matrix.ServerName {
util.GetLogger(httpReq.Context()).WithError(err).Error("domain != cfg.Matrix.ServerName failed")
return jsonerror.InternalServerError()
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.InvalidArgumentValue("Domain does not match this server."),
}
}
profile, err := appserviceAPI.RetrieveUserProfile(httpReq.Context(), userID, asAPI, accountDB)