From 0a48aa5616ea4215a9af0736921d6bd910259ac2 Mon Sep 17 00:00:00 2001 From: James Kirk <james.kirk@noc.ac.uk> Date: Thu, 2 Mar 2023 14:33:25 +0000 Subject: [PATCH] refactor: returns into aborts --- endpoints/client.py | 4 ++-- endpoints/notify.py | 2 +- endpoints/send.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/endpoints/client.py b/endpoints/client.py index 469ff83..0f42fea 100644 --- a/endpoints/client.py +++ b/endpoints/client.py @@ -43,7 +43,7 @@ class Client(Resource): try: args = request.get_json() except BadRequest: - return "POSTed body is invalid JSON", 400 + abort(400, message="POSTed body is invalid JSON") errors = self.schema.validate(args) if errors: @@ -73,7 +73,7 @@ class ClientList(Resource): try: args = request.get_json() except BadRequest: - return "POSTed body is invalid JSON", 400 + abort(400, message="POSTed body is invalid JSON") errors = self.schema.validate(args) if errors: diff --git a/endpoints/notify.py b/endpoints/notify.py index 3035e79..f3dd916 100644 --- a/endpoints/notify.py +++ b/endpoints/notify.py @@ -24,7 +24,7 @@ class Notify(AuthResource): try: args = request.get_json() except BadRequest: - return "POSTed body is invalid JSON", 400 + abort(400, message="POSTed body is invalid JSON") errors = self.schema.validate(args) if errors: diff --git a/endpoints/send.py b/endpoints/send.py index edb5277..90d519a 100644 --- a/endpoints/send.py +++ b/endpoints/send.py @@ -25,7 +25,7 @@ class Send(AuthResource): try: args = request.get_json() except BadRequest: - return "POSTed body is invalid JSON", 400 + abort(400, message="POSTed body is invalid JSON") errors = self.schema.validate(args) if errors: -- GitLab