Remove vestigial error handling code

LabThings now handles HTTPErrors properly, so I am removing
this copy-pasted workaround.
This commit is contained in:
Richard Bowman 2021-08-23 16:08:50 +01:00
parent 76a807fba5
commit 6a484514a9

View file

@ -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