From a53774721a90955cfb6180d332ca9f54f9b5e58a Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Fri, 26 Feb 2016 10:22:35 +0100 Subject: Add error codes for malformed/bad JSON in /login Signed-off-by: Gergely Polonkai --- synapse/rest/client/v1/login.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'synapse/rest/client') diff --git a/synapse/rest/client/v1/login.py b/synapse/rest/client/v1/login.py index 79101106ac..a4f89aea7b 100644 --- a/synapse/rest/client/v1/login.py +++ b/synapse/rest/client/v1/login.py @@ -404,10 +404,10 @@ def _parse_json(request): try: content = json.loads(request.content.read()) if type(content) != dict: - raise SynapseError(400, "Content must be a JSON object.") + raise SynapseError(400, "Content must be a JSON object.", errcode=Codes.BAD_JSON) return content except ValueError: - raise SynapseError(400, "Content not JSON.") + raise SynapseError(400, "Content not JSON.", errcode=Codes.NOT_JSON) def register_servlets(hs, http_server): -- cgit 1.4.1 From 87acd8fb075114849ca06188ef333119ea73ad12 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Fri, 26 Feb 2016 12:05:38 +0100 Subject: Fix to appease the PEP8 dragon --- synapse/rest/client/v1/login.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'synapse/rest/client') diff --git a/synapse/rest/client/v1/login.py b/synapse/rest/client/v1/login.py index a4f89aea7b..f13272da8e 100644 --- a/synapse/rest/client/v1/login.py +++ b/synapse/rest/client/v1/login.py @@ -404,7 +404,9 @@ def _parse_json(request): try: content = json.loads(request.content.read()) if type(content) != dict: - raise SynapseError(400, "Content must be a JSON object.", errcode=Codes.BAD_JSON) + raise SynapseError( + 400, "Content must be a JSON object.", errcode=Codes.BAD_JSON + ) return content except ValueError: raise SynapseError(400, "Content not JSON.", errcode=Codes.NOT_JSON) -- cgit 1.4.1