From 3ddd63701e9a02fb48c631a9657eb90402565d24 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Tue, 30 Jul 2013 21:29:47 +0200 Subject: [PATCH] Added default error handler. --- src/main.py | 7 ++++++- src/templates/layout.html | 27 ++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/main.py b/src/main.py index f661c1a..53e9765 100644 --- a/src/main.py +++ b/src/main.py @@ -20,7 +20,7 @@ from api.controller.entries import * from api.controller.accounts import * from api.controller.scheduled_operations import * -from flask import redirect, render_template +from flask import redirect, render_template, jsonify @app.route('/') def root(): @@ -34,6 +34,11 @@ def index(): def scheduler(): return render_template('scheduler.html') +@app.errorhandler(BaseException) +def default_errorhandler(error): + print "An error occured: %s" % error + return jsonify(title="Error", text="Error %s" % str(error)), 500 + if __name__ == '__main__': app.run(debug=True) diff --git a/src/templates/layout.html b/src/templates/layout.html index fb33445..9fa9d23 100644 --- a/src/templates/layout.html +++ b/src/templates/layout.html @@ -114,9 +114,30 @@ {% block js %}{% endblock %}