Code

svn repository setup
[roundup.git] / roundup / cgi / exceptions.py
1 #$Id: exceptions.py,v 1.6 2004-11-18 14:10:27 a1s 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 LoginError(HTTPException):
13     pass
15 class Unauthorised(HTTPException):
16     pass
18 class Redirect(HTTPException):
19     pass
21 class NotFound(HTTPException):
22     pass
24 class NotModified(HTTPException):
25     pass
27 class FormError(ValueError):
28     """An 'expected' exception occurred during form parsing.
30     That is, something we know can go wrong, and don't want to alarm the user
31     with.
33     We trap this at the user interface level and feed back a nice error to the
34     user.
36     """
37     pass
39 class SendFile(Exception):
40     """Send a file from the database."""
42 class SendStaticFile(Exception):
43     """Send a static file from the instance html directory."""
45 class SeriousError(Exception):
46     """Raised when we can't reasonably display an error message on a
47     templated page.
49     The exception value will be displayed in the error page, HTML
50     escaped.
51     """
52     def __str__(self):
53         return '''
54 <html><head><title>Roundup issue tracker: An error has occurred</title>
55  <link rel="stylesheet" type="text/css" href="@@file/style.css">
56 </head>
57 <body class="body" marginwidth="0" marginheight="0">
58  <p class="error-message">%s</p>
59 </body></html>
60 '''%cgi.escape(self.args[0])
62 # vim: set filetype=python sts=4 sw=4 et si :