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