]> git.decadent.org.uk Git - dak.git/blob - daklib/dak_exceptions.py
Merge commit 'ftpmaster/master' into regexes
[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         Exception.__init__(self)
33         self.args = str(message)
34         self.message = str(message)
35
36     def __str__(self):
37         return self.message
38
39 __all__ = ['DakError']
40
41 dakerrors = {
42     "ParseMaintError":     """Exception raised for errors in parsing a maintainer field.""",
43     "ParseChangesError":   """Exception raised for errors in parsing a changes file.""",
44     "InvalidDscError":     """Exception raised for invalid dsc files.""",
45     "UnknownFormatError":  """Exception raised for unknown Format: lines in changes files.""",
46     "NoFilesFieldError":   """Exception raised for missing files field in dsc/changes.""",
47     "CantOpenError":       """Exception raised when files can't be opened.""",
48     "CantOverwriteError":  """Exception raised when files can't be overwritten.""",
49     "FileExistsError":     """Exception raised when destination file exists.""",
50     "SendmailFailedError": """Exception raised when Sendmail invocation failed.""",
51     "NoFreeFilenameError": """Exception raised when no alternate filename was found.""",
52     "TransitionsError":    """Exception raised when transitions file can't be parsed.""",
53     "NoSourceFieldError":  """Exception raised - we cant find the source - wtf?"""
54 }
55
56 def construct_dak_exception(name, description):
57     class Er(DakError):
58         __doc__ = description
59     setattr(Er, "__name__", name)
60     return Er
61
62 for e in dakerrors.keys():
63     globals()[e] = construct_dak_exception(e, dakerrors[e])
64     __all__ += [e]
65
66
67
68 ################################################################################