Code

add and use Reject exception (sf bug 700265)
[roundup.git] / roundup / cgi / exceptions.py
1 #$Id: exceptions.py,v 1.4 2004-03-26 00:44:11 richard Exp $
2 '''Exceptions for use in Roundup's web interface.
3 '''
5 __docformat__ = 'restructuredtext'
7 import cgi
9 class HTTPException(Exception):
10     pass
12 class Unauthorised(HTTPException):
13     pass
15 class Redirect(HTTPException):
16     pass
18 class NotFound(HTTPException):
19     pass
21 class NotModified(HTTPException):
22     pass
24 class FormError(ValueError):
25     """An 'expected' exception occurred during form parsing.
27     That is, something we know can go wrong, and don't want to alarm the user
28     with.
30     We trap this at the user interface level and feed back a nice error to the
31     user.
33     """
34     pass
36 class SendFile(Exception):
37     """Send a file from the database."""
39 class SendStaticFile(Exception):
40     """Send a static file from the instance html directory."""
42 class SeriousError(Exception):
43     """Raised when we can't reasonably display an error message on a
44     templated page.
46     The exception value will be displayed in the error page, HTML
47     escaped.
48     """
49     def __str__(self):
50         return '''
51 <html><head><title>Roundup issue tracker: An error has occurred</title>
52  <meta http-equiv="Content-Type" content="text/html; charset=utf-8;">
53  <link rel="stylesheet" type="text/css" href="_file/style.css">
54 </head>
55 <body class="body" marginwidth="0" marginheight="0">
56  <p class="error-message">%s</p>
57 </body></html>
58 '''%cgi.escape(self.args[0])
60 # vim: set filetype=python ts=4 sw=4 et si