Blame view

app/errors/handlers.py 946 Bytes
775de511   hitier   Error handlers fo...
1
2
3
4
from flask import render_template
from app import db
from . import bp

775de511   hitier   Error handlers fo...
5
6
7
# Inspired by:
#   https://flask.palletsprojects.com/en/master/patterns/errorpages/

65b2833e   hitier   Fix some sonar co...
8
9
10
error_page = 'error.html'


775de511   hitier   Error handlers fo...
11
12
13
@bp.app_errorhandler(403)
def forbidden_error(error):
    error_title = "Page Interdite"
65b2833e   hitier   Fix some sonar co...
14
    return render_template(error_page, error_title=error_title, error_msg=error), 403
775de511   hitier   Error handlers fo...
15
16
17
18
19


@bp.app_errorhandler(404)
def not_found_error(error):
    error_title = "Page Introuvable."
65b2833e   hitier   Fix some sonar co...
20
    return render_template(error_page, error_title=error_title, error_msg=error), 404
775de511   hitier   Error handlers fo...
21
22
23
24
25


@bp.app_errorhandler(405)
def method_error(error):
    error_title = "Erreur de Méthode."
65b2833e   hitier   Fix some sonar co...
26
    return render_template(error_page, error_title=error_title, error_msg=error), 405
775de511   hitier   Error handlers fo...
27
28
29
30
31
32


@bp.app_errorhandler(500)
def internal_error(error):
    db.session.rollback()
    error_title = "Erreur Interne. Administrateur Prévenu."
65b2833e   hitier   Fix some sonar co...
33
    return render_template(error_page, error_title=error_title, error_msg=error), 500