Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

vigiboard / vigiboard / lib / error_handler.py @ 2bcebf54

History | View | Annotate | Download (1.41 KB)

1
# vim: set fileencoding=utf-8 sw=4 ts=4 et :
2
################################################################################
3
#
4
# Copyright (C) 2007-2016 CS-SI
5
#
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License version 2 as
8
# published by the Free Software Foundation.
9
#
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
################################################################################
19

    
20
"""Fonction de gestion des messages d'erreur"""
21

    
22
import logging
23

    
24
from tg import flash, redirect
25

    
26
LOGGER = logging.getLogger(__name__)
27

    
28
def handle_error_message(message, redirection_url='./'):
29
    """
30
    Affiche le message dans l'IHM, l'enregistre dans les logs
31
    et renvoie le navigateur vers l'URL de redirection.
32

33
    @param message: message d'erreur à afficher
34
    @type  message: C{str}
35
    @param redirection_url: (optionnel) URL de redirection
36
    @type  redirection_url: C{str}
37
    """
38
    LOGGER.error(message)
39
    flash(message, 'error')
40
    redirect(redirection_url)