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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# Copyright (C) 1998-2016 by the Free Software Foundation, Inc.
#
# This file is part of GNU Mailman.
#
# GNU Mailman is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
"""Legacy Mailman exceptions.
This module is largely obsolete, though not all exceptions in use have been
migrated to their proper location. There are still a number of Mailman 2.1
exceptions floating about in here too.
The right place for exceptions is in the interface module for their related
interfaces.
"""
__all__ = [
'DiscardMessage',
'HandlerError',
'HoldMessage',
'LostHeldMessage',
'RESTError',
'ReadOnlyPATCHRequestError',
'RejectMessage',
'UnknownPATCHRequestError',
]
class MailmanError(Exception):
"""Base class for all Mailman errors."""
pass
# Exceptions for admin request database
class LostHeldMessage(MailmanError):
"""Held message was lost."""
pass
def _(s):
return s
# Exceptions for the Handler subsystem
class HandlerError(MailmanError):
"""Base class for all handler errors."""
def __init__(self, message=None):
self.message = message
def __str__(self):
return self.message
class HoldMessage(HandlerError):
"""Base class for all message-being-held short circuits."""
# funky spelling is necessary to break import loops
reason = _('For some unknown reason')
def reason_notice(self):
return self.reason
# funky spelling is necessary to break import loops
rejection = _('Your message was rejected')
def rejection_notice(self, mlist):
return self.rejection
class DiscardMessage(HandlerError):
"""The message can be discarded with no further action"""
class RejectMessage(HandlerError):
"""The message will be bounced back to the sender"""
class RESTError(MailmanError):
"""Base class for REST API errors."""
class UnknownPATCHRequestError(RESTError):
"""A PATCH request contained an unknown attribute."""
def __init__(self, attribute):
self.attribute = attribute
class ReadOnlyPATCHRequestError(RESTError):
"""A PATCH request contained a read-only attribute."""
def __init__(self, attribute):
self.attribute = attribute
|