Code

29298952c7096fb7d75477eb5099a3227877959c
[roundup.git] / roundup / cgi / exceptions.py
1 import cgi
3 class HTTPException(Exception):
4     pass
6 class Unauthorised(HTTPException):
7     pass
9 class Redirect(HTTPException):
10     pass
12 class NotFound(HTTPException):
13     pass
15 class NotModified(HTTPException):
16     pass
18 class FormError(ValueError):
19     """An 'expected' exception occurred during form parsing.
21     That is, something we know can go wrong, and don't want to alarm the user
22     with.
24     We trap this at the user interface level and feed back a nice error to the
25     user.
27     """
28     pass
30 class SendFile(Exception):
31     """Send a file from the database."""
33 class SendStaticFile(Exception):
34     """Send a static file from the instance html directory."""
36 class SeriousError(Exception):
37     """Raised when we can't reasonably display an error message on a
38     templated page.
40     The exception value will be displayed in the error page, HTML
41     escaped.
42     """
43     def __str__(self):
44         return '''
45 <html><head><title>Roundup issue tracker: An error has occurred</title>
46  <meta http-equiv="Content-Type" content="text/html; charset=utf-8;">
47  <link rel="stylesheet" type="text/css" href="_file/style.css">
48 </head>
49 <body class="body" marginwidth="0" marginheight="0">
50  <p class="error-message">%s</p>
51 </body></html>
52 '''%cgi.escape(self.args[0])