Skip to content

Commit c4f5776

Browse files
committed
issue2551083 Replace BaseException and Exception with RoundupException
issue2551083 - Replace BaseException and Exception as base classes with new RoundupException (inheriting from Exception) for most roundup exceptions.
1 parent 78e0a92 commit c4f5776

File tree

7 files changed

+33
-15
lines changed

7 files changed

+33
-15
lines changed

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ Features:
6262
(Christof Meerwald)
6363
- Allow filtering by multiple date ranges or empty date. Date ranges are
6464
separated by comma, an empty date is represented by '-'
65+
- issue2551083 - Replace BaseException and Exception as base classes
66+
with new RoundupException (inheriting from Exception) for most
67+
roundup exceptions. (John Rouillard and Ralf Schlatterbeck on
68+
request from Robert Klonner.)
6569

6670
Fixed:
6771

roundup/cgi/exceptions.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77

88
from roundup.anypy.html import html_escape
99

10+
from roundup.exceptions import RoundupException
1011

11-
class HTTPException(BaseException):
12+
class RoundupCGIException(RoundupException):
13+
pass
14+
15+
class HTTPException(RoundupCGIException):
1216
pass
1317

1418

@@ -28,7 +32,7 @@ class PreconditionFailed(HTTPException):
2832
pass
2933

3034

31-
class DetectorError(BaseException):
35+
class DetectorError(RoundupException):
3236
"""Raised when a detector throws an exception.
3337
Contains details of the exception."""
3438
def __init__(self, subject, html, txt):
@@ -51,15 +55,15 @@ class FormError(ValueError):
5155
pass
5256

5357

54-
class SendFile(BaseException):
58+
class SendFile(RoundupException):
5559
"""Send a file from the database."""
5660

5761

58-
class SendStaticFile(BaseException):
62+
class SendStaticFile(RoundupException):
5963
"""Send a static file from the instance html directory."""
6064

6165

62-
class SeriousError(BaseException):
66+
class SeriousError(RoundupException):
6367
"""Raised when we can't reasonably display an error message on a
6468
templated page.
6569

roundup/cgi/templating.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ def anti_csrf_nonce(client, lifetime=None):
167167

168168
### templating
169169

170-
class NoTemplate(BaseException):
170+
class NoTemplate(RoundupException):
171171
pass
172172

173-
class Unauthorised(BaseException):
173+
class Unauthorised(RoundupException):
174174
def __init__(self, action, klass, translator=None):
175175
self.action = action
176176
self.klass = klass

roundup/configuration.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@
2929
else:
3030
import ConfigParser as configparser # Python 2
3131

32+
from exceptions import RoundupException
33+
3234
# XXX i don't think this module needs string translation, does it?
3335

3436
### Exceptions
3537

3638

37-
class ConfigurationError(BaseException):
39+
class ConfigurationError(RoundupException):
3840
pass
3941

4042

roundup/exceptions.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@
44
__docformat__ = 'restructuredtext'
55

66

7-
class LoginError(BaseException):
7+
class RoundupException(Exception):
8+
pass
9+
10+
class LoginError(RoundupException):
811
pass
912

1013

11-
class Unauthorised(BaseException):
14+
class Unauthorised(RoundupException):
1215
pass
1316

17+
class RejectBase(RoundupException):
18+
pass
1419

15-
class Reject(BaseException):
20+
class Reject(RejectBase):
1621
"""An auditor may raise this exception when the current create or set
1722
operation should be stopped.
1823

roundup/instance.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
from roundup import hyperdb, backends, actions
4747
from roundup.cgi import client, templating
4848
from roundup.cgi import actions as cgi_actions
49+
from roundup.exceptions import RoundupException
4950

5051

5152
class Tracker:
@@ -271,7 +272,7 @@ def registerUtil(self, name, function):
271272
self.templating_utils[name] = function
272273

273274

274-
class TrackerError(BaseException):
275+
class TrackerError(RoundupException):
275276
pass
276277

277278

roundup/mailgw.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ class node. Any parts of other types are each stored in separate files
118118
except ImportError:
119119
gpg = None
120120

121+
from exceptions import RoundupException
122+
121123
SENDMAILDEBUG = os.environ.get('SENDMAILDEBUG', '')
122124

123125

@@ -129,17 +131,17 @@ class MailUsageError(ValueError):
129131
pass
130132

131133

132-
class MailUsageHelp(BaseException):
134+
class MailUsageHelp(RoundupException):
133135
""" We need to send the help message to the user. """
134136
pass
135137

136138

137-
class Unauthorized(BaseException):
139+
class Unauthorized(RoundupException):
138140
""" Access denied """
139141
pass
140142

141143

142-
class IgnoreMessage(BaseException):
144+
class IgnoreMessage(RoundupException):
143145
""" A general class of message that we should ignore. """
144146
pass
145147

0 commit comments

Comments
 (0)