Use NotJSON instead of BadJSON when the JSON couldn't be decoded

This commit is contained in:
Mark Haines 2017-08-23 14:43:54 +01:00
parent 4e8ba59db3
commit 54979214ca
2 changed files with 5 additions and 4 deletions

View file

@ -34,7 +34,7 @@ func Invite(
if err := json.Unmarshal(request.Content(), &event); err != nil {
return util.JSONResponse{
Code: 400,
JSON: jsonerror.BadJSON("The request body could not be decoded into valid JSON. " + err.Error()),
JSON: jsonerror.NotJSON("The request body could not be decoded into valid JSON. " + err.Error()),
}
}

View file

@ -3,6 +3,9 @@ package writers
import (
"encoding/json"
"fmt"
"net/http"
"time"
"github.com/matrix-org/dendrite/clientapi/httputil"
"github.com/matrix-org/dendrite/clientapi/jsonerror"
"github.com/matrix-org/dendrite/clientapi/producers"
@ -10,8 +13,6 @@ import (
"github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util"
"net/http"
"time"
)
// Send implements /_matrix/federation/v1/send/{txnID}
@ -39,7 +40,7 @@ func Send(
if err := json.Unmarshal(request.Content(), &t); err != nil {
return util.JSONResponse{
Code: 400,
JSON: jsonerror.BadJSON("The request body could not be decoded into valid JSON. " + err.Error()),
JSON: jsonerror.NotJSON("The request body could not be decoded into valid JSON. " + err.Error()),
}
}