From 6a484514a995ec53103eff9783b24d84c43119ca Mon Sep 17 00:00:00 2001 From: Richard Bowman Date: Mon, 23 Aug 2021 16:08:50 +0100 Subject: [PATCH 1/2] Remove vestigial error handling code LabThings now handles HTTPErrors properly, so I am removing this copy-pasted workaround. --- openflexure_microscope/api/app.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/openflexure_microscope/api/app.py b/openflexure_microscope/api/app.py index 444fc7fc..230dd35e 100644 --- a/openflexure_microscope/api/app.py +++ b/openflexure_microscope/api/app.py @@ -108,19 +108,6 @@ app, labthing = create_app( # Enable CORS for some routes outside of LabThings cors: CORS = CORS(app) -# Enable correct handling of Marshmallow/Webargs validation errors -# Return validation errors as JSON -# (see https://webargs.readthedocs.io/en/latest/framework_support.html) -@app.errorhandler(422) -@app.errorhandler(400) -def handle_error(err): - headers = err.data.get("headers", None) - messages = err.data.get("messages", ["Invalid request."]) - if headers: - return jsonify({"errors": messages}), err.code, headers - else: - return jsonify({"errors": messages}), err.code - # Use custom JSON encoder labthing.json_encoder = JSONEncoder From ae96340d791a166fe60dc1e6706e77c9388c25fd Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 23 Aug 2021 20:53:04 +0100 Subject: [PATCH 2/2] Remove unused import --- openflexure_microscope/api/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openflexure_microscope/api/app.py b/openflexure_microscope/api/app.py index 230dd35e..95908a51 100644 --- a/openflexure_microscope/api/app.py +++ b/openflexure_microscope/api/app.py @@ -24,7 +24,7 @@ import os from datetime import datetime import pkg_resources -from flask import abort, jsonify, send_file +from flask import abort, send_file from flask_cors import CORS, cross_origin from labthings import create_app from labthings.extensions import find_extensions