Added default error handler.
This commit is contained in:
parent
2a9f5b2500
commit
3ddd63701e
@ -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)
|
||||
|
||||
|
@ -114,9 +114,30 @@
|
||||
{% block js %}{% endblock %}
|
||||
|
||||
<script type="text/javascript">
|
||||
angular.module('$strap').config(function($interpolateProvider) {
|
||||
angular.module('$strap').config(function($interpolateProvider, $httpProvider) {
|
||||
$interpolateProvider.startSymbol('[[');
|
||||
$interpolateProvider.endSymbol(']]');
|
||||
|
||||
$httpProvider.responseInterceptors.push(['$rootScope', '$q', function(scope, $q) {
|
||||
function success(response) {
|
||||
return response;
|
||||
}
|
||||
|
||||
function error(response) {
|
||||
$.pnotify({
|
||||
type: "error",
|
||||
title: response.data.title,
|
||||
text: response.data.text,
|
||||
width: 500px
|
||||
})
|
||||
|
||||
return $q.reject(response);
|
||||
}
|
||||
|
||||
return function(promise) {
|
||||
return promise.then(success, error);
|
||||
}
|
||||
}]);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user