]> git.decadent.org.uk Git - dak.git/blob - daklib/dak_exceptions.py
Merge from Joachim
[dak.git] / daklib / dak_exceptions.py
1 # Exception classes used in dak
2
3 # Copyright (C) 2008  Mark Hymers <mhy@debian.org>
4
5 ################################################################################
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21 ################################################################################
22
23 class DakError(Exception):
24     """Base class for all simple errors in this module.
25
26     Attributes:
27
28        message -- explanation of the error
29     """
30
31     def __init__(self, message=""):
32         self.args = str(message)
33         self.message = str(message)
34
35     def __str__(self):
36         return self.message
37
38 __all__ = ['DakError']
39
40 dakerrors = {
41     "ParseMaintError":     """Exception raised for errors in parsing a maintainer field.""",
42     "ParseChangesError":   """Exception raised for errors in parsing a changes file.""",
43     "InvalidDscError":     """Exception raised for invalid dsc files.""",
44     "UnknownFormatError":  """Exception raised for unknown Format: lines in changes files.""",
45     "NoFilesFieldError":   """Exception raised for missing files field in dsc/changes.""",
46     "CantOpenError":       """Exception raised when files can't be opened.""",
47     "CantOverwriteError":  """Exception raised when files can't be overwritten.""",
48     "FileExistsError":     """Exception raised when destination file exists.""",
49     "SendmailFailedError": """Exception raised when Sendmail invocation failed.""",
50     "NoFreeFilenameError": """Exception raised when no alternate filename was found.""",
51     "TransitionsError":    """Exception raised when transitions file can't be parsed.""",
52     "NoSourceFieldError":  """Exception raised - we cant find the source - wtf?"""
53 }
54
55 def construct_dak_exception(name, description):
56     class Er(DakError):
57         __doc__ = description
58     setattr(Er, "__name__", name)
59     return Er
60
61 for e in dakerrors.keys():
62     globals()[e] = construct_dak_exception(e, dakerrors[e])
63     __all__ += [e]
64
65
66
67 ################################################################################