Salome HOME
sauve du 20/12
[tools/eficas.git] / Noyau / N_Exception.py
1 # coding=utf-8
2 # person_in_charge: mathieu.courtois at edf.fr
3 # ======================================================================
4 # COPYRIGHT (C) 1991 - 2015  EDF R&D                  WWW.CODE-ASTER.ORG
5 # THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
6 # IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY
7 # THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR
8 # (AT YOUR OPTION) ANY LATER VERSION.
9 #
10 # THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
11 # WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
12 # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
13 # 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 EDF R&D CODE_ASTER,
17 #    1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.
18 #
19 #
20 # ======================================================================
21
22 """
23    Ce module contient la classe AsException
24 """
25
26 # Modules EFICAS
27 from strfunc import get_encoding, to_unicode
28
29
30 class AsException(Exception):
31
32     def __unicode__(self):
33         args = []
34         for x in self.args:
35             ustr = to_unicode(x)
36             if type(ustr) is not unicode:
37                 ustr = unicode( repr(x) )
38             args.append(ustr)
39         return " ".join(args)
40
41     def __str__(self):
42         return unicode(self).encode(get_encoding())
43
44
45 class InterruptParsingError(Exception):
46
47     """Exception used to interrupt the parsing of the command file
48     without raising an error (see N_JDC.exec_compile for usage)"""