From 6863d03374374721288f9389a9e7a3b302cadbaf Mon Sep 17 00:00:00 2001 From: josiah Date: Thu, 29 Apr 2021 18:01:08 -0500 Subject: [PATCH] Further linting issues. --- warren/app.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/warren/app.py b/warren/app.py index 2f19a45..9664fa4 100644 --- a/warren/app.py +++ b/warren/app.py @@ -74,6 +74,13 @@ def write_to_db(data, dbpath): conn.close() +@app.errorhandler(Exception) +def server_error(err): + """catch all exception handler""" + app.logger.exception(err) + return "exception", 400 + + @app.route("/") def test(): """healthcheck endpoint with no logic; useful for loadbalancing checks.""" @@ -83,12 +90,9 @@ def test(): @app.route("/weir", methods=["POST"]) def weir(): """Primary app route.""" - try: - python_dict = request.get_json() - write_to_db(python_dict, "warren.db") - return "OK" - except Exception as error: - return f"Error: {error}.", 400 + python_dict = request.get_json() + write_to_db(python_dict, "warren.db") + return "OK" if __name__ == "__main__":