mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-30 21:12:45 +00:00
Move json errors over to gmsl (#3080)
This commit is contained in:
parent
a49c9f01e2
commit
0489d16f95
109 changed files with 808 additions and 1217 deletions
|
@ -27,7 +27,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||
fs "github.com/matrix-org/dendrite/federationapi/api"
|
||||
"github.com/matrix-org/dendrite/internal/hooks"
|
||||
"github.com/matrix-org/dendrite/internal/httputil"
|
||||
|
@ -169,7 +168,7 @@ func eventRelationshipHandler(db Database, rsAPI roomserver.RoomserverInternalAP
|
|||
util.GetLogger(req.Context()).WithError(err).Error("failed to decode HTTP request as JSON")
|
||||
return util.JSONResponse{
|
||||
Code: 400,
|
||||
JSON: jsonerror.BadJSON(fmt.Sprintf("invalid json: %s", err)),
|
||||
JSON: spec.BadJSON(fmt.Sprintf("invalid json: %s", err)),
|
||||
}
|
||||
}
|
||||
rc := reqCtx{
|
||||
|
@ -201,7 +200,7 @@ func federatedEventRelationship(
|
|||
util.GetLogger(ctx).WithError(err).Error("failed to decode HTTP request as JSON")
|
||||
return util.JSONResponse{
|
||||
Code: 400,
|
||||
JSON: jsonerror.BadJSON(fmt.Sprintf("invalid json: %s", err)),
|
||||
JSON: spec.BadJSON(fmt.Sprintf("invalid json: %s", err)),
|
||||
}
|
||||
}
|
||||
rc := reqCtx{
|
||||
|
@ -268,7 +267,7 @@ func (rc *reqCtx) process() (*MSC2836EventRelationshipsResponse, *util.JSONRespo
|
|||
if event == nil || !rc.authorisedToSeeEvent(event) {
|
||||
return nil, &util.JSONResponse{
|
||||
Code: 403,
|
||||
JSON: jsonerror.Forbidden("Event does not exist or you are not authorised to see it"),
|
||||
JSON: spec.Forbidden("Event does not exist or you are not authorised to see it"),
|
||||
}
|
||||
}
|
||||
rc.roomVersion = event.Version()
|
||||
|
@ -428,7 +427,7 @@ func (rc *reqCtx) includeChildren(db Database, parentID string, limit int, recen
|
|||
children, err := db.ChildrenForParent(rc.ctx, parentID, constRelType, recentFirst)
|
||||
if err != nil {
|
||||
util.GetLogger(rc.ctx).WithError(err).Error("failed to get ChildrenForParent")
|
||||
resErr := jsonerror.InternalServerError()
|
||||
resErr := spec.InternalServerError()
|
||||
return nil, &resErr
|
||||
}
|
||||
var childEvents []*types.HeaderedEvent
|
||||
|
|
|
@ -28,7 +28,6 @@ import (
|
|||
|
||||
"github.com/google/uuid"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||
fs "github.com/matrix-org/dendrite/federationapi/api"
|
||||
"github.com/matrix-org/dendrite/internal/caching"
|
||||
"github.com/matrix-org/dendrite/internal/httputil"
|
||||
|
@ -96,7 +95,7 @@ func federatedSpacesHandler(
|
|||
if err != nil {
|
||||
return util.JSONResponse{
|
||||
Code: 400,
|
||||
JSON: jsonerror.InvalidParam("bad request uri"),
|
||||
JSON: spec.InvalidParam("bad request uri"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,13 +213,13 @@ func (w *walker) walk() util.JSONResponse {
|
|||
// CS API format
|
||||
return util.JSONResponse{
|
||||
Code: 403,
|
||||
JSON: jsonerror.Forbidden("room is unknown/forbidden"),
|
||||
JSON: spec.Forbidden("room is unknown/forbidden"),
|
||||
}
|
||||
} else {
|
||||
// SS API format
|
||||
return util.JSONResponse{
|
||||
Code: 404,
|
||||
JSON: jsonerror.NotFound("room is unknown/forbidden"),
|
||||
JSON: spec.NotFound("room is unknown/forbidden"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -233,7 +232,7 @@ func (w *walker) walk() util.JSONResponse {
|
|||
if cache == nil {
|
||||
return util.JSONResponse{
|
||||
Code: 400,
|
||||
JSON: jsonerror.InvalidArgumentValue("invalid from"),
|
||||
JSON: spec.InvalidParam("invalid from"),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -377,7 +376,7 @@ func (w *walker) walk() util.JSONResponse {
|
|||
if len(discoveredRooms) == 0 {
|
||||
return util.JSONResponse{
|
||||
Code: 404,
|
||||
JSON: jsonerror.NotFound("room is unknown/forbidden"),
|
||||
JSON: spec.NotFound("room is unknown/forbidden"),
|
||||
}
|
||||
}
|
||||
return util.JSONResponse{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue