Mercurial > p > roundup > code
annotate roundup/exceptions.py @ 8408:e882a5d52ae5
refactor: move RateLimitExceeded to roundup.cgi.exceptions
RateLimitExceeded is an HTTP exception that raises code 429. Move it
to roundup.cgi.exceptions where all the other exceptions that result
in http status codes are located. Also make it inherit from
HTTPException since it is one.
Also add docstrings for all HTTP exceptions and order HTTPExceptions
by status code.
BREAKING CHANGE: if somebody is importing RateLimitExceeded they will
need to change their import. I consider it unlikely anybody is using
RateLimitExceeded. Detectors and extensions are unlikely to raise
RateLimitExceeded. So I am leaving it out of the upgrading doc. Just
doc in change log.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 10 Aug 2025 21:27:06 -0400 |
| parents | 273c8c2b5042 |
| children |
| rev | line source |
|---|---|
| 4083 | 1 """Exceptions for use across all Roundup components. |
| 2 """ | |
|
2129
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
3 |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
4 __docformat__ = 'restructuredtext' |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
5 |
| 6005 | 6 |
|
6123
c177e7128dc9
issue2551083 Replace BaseException and Exception with RoundupException
John Rouillard <rouilj@ieee.org>
parents:
6005
diff
changeset
|
7 class RoundupException(Exception): |
|
c177e7128dc9
issue2551083 Replace BaseException and Exception with RoundupException
John Rouillard <rouilj@ieee.org>
parents:
6005
diff
changeset
|
8 pass |
|
c177e7128dc9
issue2551083 Replace BaseException and Exception with RoundupException
John Rouillard <rouilj@ieee.org>
parents:
6005
diff
changeset
|
9 |
|
7172
e16b7d47fdb2
chore: flake8 formatting fixes
John Rouillard <rouilj@ieee.org>
parents:
6123
diff
changeset
|
10 |
|
6123
c177e7128dc9
issue2551083 Replace BaseException and Exception with RoundupException
John Rouillard <rouilj@ieee.org>
parents:
6005
diff
changeset
|
11 class LoginError(RoundupException): |
| 4083 | 12 pass |
| 13 | |
| 6005 | 14 |
|
6123
c177e7128dc9
issue2551083 Replace BaseException and Exception with RoundupException
John Rouillard <rouilj@ieee.org>
parents:
6005
diff
changeset
|
15 class Unauthorised(RoundupException): |
| 4083 | 16 pass |
| 17 | |
|
7172
e16b7d47fdb2
chore: flake8 formatting fixes
John Rouillard <rouilj@ieee.org>
parents:
6123
diff
changeset
|
18 |
|
6123
c177e7128dc9
issue2551083 Replace BaseException and Exception with RoundupException
John Rouillard <rouilj@ieee.org>
parents:
6005
diff
changeset
|
19 class RejectBase(RoundupException): |
|
c177e7128dc9
issue2551083 Replace BaseException and Exception with RoundupException
John Rouillard <rouilj@ieee.org>
parents:
6005
diff
changeset
|
20 pass |
| 6005 | 21 |
|
7172
e16b7d47fdb2
chore: flake8 formatting fixes
John Rouillard <rouilj@ieee.org>
parents:
6123
diff
changeset
|
22 |
|
6123
c177e7128dc9
issue2551083 Replace BaseException and Exception with RoundupException
John Rouillard <rouilj@ieee.org>
parents:
6005
diff
changeset
|
23 class Reject(RejectBase): |
| 4083 | 24 """An auditor may raise this exception when the current create or set |
|
2129
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
25 operation should be stopped. |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
26 |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
27 It is up to the specific interface invoking the create or set to |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
28 handle this exception sanely. For example: |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
29 |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
30 - mailgw will trap and ignore Reject for file attachments and messages |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
31 - cgi will trap and present the exception in a nice format |
| 4083 | 32 """ |
|
2129
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
33 pass |
|
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
34 |
|
5004
494d255043c9
Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents:
4083
diff
changeset
|
35 |
|
494d255043c9
Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents:
4083
diff
changeset
|
36 class RejectRaw(Reject): |
|
494d255043c9
Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents:
4083
diff
changeset
|
37 """ |
|
494d255043c9
Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents:
4083
diff
changeset
|
38 Performs the same function as Reject, except HTML in the message is not |
|
494d255043c9
Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents:
4083
diff
changeset
|
39 escaped when displayed to the user. |
|
494d255043c9
Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents:
4083
diff
changeset
|
40 """ |
|
494d255043c9
Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents:
4083
diff
changeset
|
41 pass |
|
494d255043c9
Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents:
4083
diff
changeset
|
42 |
|
494d255043c9
Display errors containing HTML with RejectRaw (issue2550847)
John Kristensen <john@jerrykan.com>
parents:
4083
diff
changeset
|
43 |
|
4066
042ace5ddb7c
Move 'UsageError' definition from roundup.admin to roundup.exceptions.
Stefan Seefeld <stefan@seefeld.name>
parents:
2129
diff
changeset
|
44 class UsageError(ValueError): |
|
042ace5ddb7c
Move 'UsageError' definition from roundup.admin to roundup.exceptions.
Stefan Seefeld <stefan@seefeld.name>
parents:
2129
diff
changeset
|
45 pass |
|
042ace5ddb7c
Move 'UsageError' definition from roundup.admin to roundup.exceptions.
Stefan Seefeld <stefan@seefeld.name>
parents:
2129
diff
changeset
|
46 |
|
2129
3fd672293712
add and use Reject exception [SF#700265]
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
47 # vim: set filetype=python ts=4 sw=4 et si |
