Move json errors over to gmsl (#3080)

This commit is contained in:
devonh 2023-05-09 22:46:49 +00:00 committed by GitHub
parent a49c9f01e2
commit 0489d16f95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
109 changed files with 808 additions and 1217 deletions

View file

@ -21,7 +21,6 @@ import (
"strconv"
"time"
"github.com/matrix-org/dendrite/clientapi/jsonerror"
"github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/dendrite/roomserver/types"
"github.com/matrix-org/dendrite/setup/config"
@ -50,7 +49,7 @@ func Backfill(
if _, _, err = gomatrixserverlib.SplitID('!', roomID); err != nil {
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.MissingArgument("Bad room ID: " + err.Error()),
JSON: spec.MissingParam("Bad room ID: " + err.Error()),
}
}
@ -65,14 +64,14 @@ func Backfill(
if !exists {
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.MissingArgument("v is missing"),
JSON: spec.MissingParam("v is missing"),
}
}
limit = httpReq.URL.Query().Get("limit")
if len(limit) == 0 {
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.MissingArgument("limit is missing"),
JSON: spec.MissingParam("limit is missing"),
}
}
@ -92,14 +91,14 @@ func Backfill(
util.GetLogger(httpReq.Context()).WithError(err).Error("strconv.Atoi failed")
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.InvalidArgumentValue(fmt.Sprintf("limit %q is invalid format", limit)),
JSON: spec.InvalidParam(fmt.Sprintf("limit %q is invalid format", limit)),
}
}
// Query the roomserver.
if err = rsAPI.PerformBackfill(httpReq.Context(), &req, &res); err != nil {
util.GetLogger(httpReq.Context()).WithError(err).Error("query.PerformBackfill failed")
return jsonerror.InternalServerError()
return spec.InternalServerError()
}
// Filter any event that's not from the requested room out.