1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
"""
# Copyright 1999-2005 Gentoo Foundation
# This source code is distributed under the terms of version 2 of the GNU
# General Public License as published by the Free Software Foundation, a copy
# of which can be found in the main directory of this project.
Gentoo Linux Installer
$Id: GLIException.py,v 1.9 2005/08/22 18:35:51 codeman Exp $
Copyright 2004 Gentoo Technologies Inc.
"""
from string import upper
class GLIException(Exception):
error_levels = ['notice', 'warning', 'fatal']
##
# Brief description of function
# @param self Parameter description
# @param error_name Parameter description
# @param error_level Parameter description
# @param function_name Parameter description
# @param error_msg Parameter description
def __init__(self, error_name, error_level, function_name, error_msg):
if error_level not in GLIException.error_levels:
raise GLIException('NoSuchLevelError', 'fatal', '__init__', "No such error level: %s" % error_level)
Exception.__init__(self, error_name, error_level, function_name, error_msg)
##
# Brief description of function
# @param self Parameter description
def get_function_name(self):
return self.args[2]
##
# Brief description of function
# @param self Parameter description
def get_error_level(self):
return self.args[1]
##
# Brief description of function
# @param self Parameter description
def get_error_msg(self):
return self.args[3]
##
# Brief description of function
# @param self Parameter description
def get_error_name(self):
return self.args[0]
##
# Brief description of function
# @param self Parameter description
def __str__(self):
return "%s :%s: %s: %s" % (self.args[0], upper(self.args[1]), self.args[2], self.args[3])
|