]> git.decadent.org.uk Git - dak.git/blob - daklib/dak_exceptions.py
Add by-hash support
[dak.git] / daklib / dak_exceptions.py
1 #!/usr/bin/env python
2
3 """
4 Exception classes used in dak
5
6 @contact: Debian FTP Master <ftpmaster@debian.org>
7 @copyright: 2008  Mark Hymers <mhy@debian.org>
8 @license: GNU General Public License version 2 or later
9 """
10
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
15
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24
25
26 class DakError(Exception):
27     """
28     Base class for all simple errors in this module.
29
30     """
31
32     def __init__(self, message=""):
33         """
34         @type message: string
35         @param message: explanation of the error
36
37         """
38         Exception.__init__(self)
39         self.args = str(message)
40         self.message = str(message)
41
42     def __str__(self):
43         return self.message
44
45 __all__ = ['DakError']
46
47 # If you want to have a new exception in dak, add it here.
48 dakerrors = {
49     "ParseMaintError":     """Exception raised for errors in parsing a maintainer field.""",
50     "ParseChangesError":   """Exception raised for errors in parsing a changes file.""",
51     "InvalidDscError":     """Exception raised for invalid dsc files.""",
52     "UnknownFormatError":  """Exception raised for unknown Format: lines in changes files.""",
53     "NoFilesFieldError":   """Exception raised for missing files field in dsc/changes.""",
54     "CantOpenError":       """Exception raised when files can't be opened.""",
55     "CantOverwriteError":  """Exception raised when files can't be overwritten.""",
56     "FileExistsError":     """Exception raised when destination file exists.""",
57     "SendmailFailedError": """Exception raised when Sendmail invocation failed.""",
58     "NoFreeFilenameError": """Exception raised when no alternate filename was found.""",
59     "TransitionsError":    """Exception raised when transitions file can't be parsed.""",
60     "NoSourceFieldError":  """Exception raised - we cant find the source - wtf?""",
61     "MissingContents":     """Exception raised - we could not determine contents for this deb""",
62     "DBUpdateError":       """Exception raised - could not update the database""",
63     "ChangesUnicodeError": """Exception raised - changes file not properly utf-8 encoded""",
64     "AlreadyLockedError":  """Exception raised - package already locked by someone else""",
65     "CantGetLockError":    """Exception raised - lockfile already in use""",
66 } #: All dak exceptions
67
68 def construct_dak_exception(name, description):
69     class Er(DakError):
70         __doc__ = description
71     setattr(Er, "__name__", name)
72     return Er
73
74 for e in dakerrors.keys():
75     globals()[e] = construct_dak_exception(e, dakerrors[e])
76     __all__ += [e]
77
78
79
80 ################################################################################