"Fossies" - the Fresh Open Source Software Archive

Member "roundup-2.0.0/roundup/cgi/exceptions.py" (3 Apr 2020, 1908 Bytes) of package /linux/www/roundup-2.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "exceptions.py": 1.6.1_vs_2.0.0.

    1 """Exceptions for use in Roundup's web interface.
    2 """
    3 
    4 __docformat__ = 'restructuredtext'
    5 
    6 from roundup.exceptions import LoginError, Unauthorised  # noqa: F401
    7 
    8 from roundup.anypy.html import html_escape
    9 
   10 from roundup.exceptions import RoundupException
   11 
   12 class RoundupCGIException(RoundupException):
   13     pass
   14 
   15 class HTTPException(RoundupCGIException):
   16     pass
   17 
   18 
   19 class Redirect(HTTPException):
   20     pass
   21 
   22 
   23 class NotFound(HTTPException):
   24     pass
   25 
   26 
   27 class NotModified(HTTPException):
   28     pass
   29 
   30 
   31 class PreconditionFailed(HTTPException):
   32     pass
   33 
   34 
   35 class DetectorError(RoundupException):
   36     """Raised when a detector throws an exception.
   37 Contains details of the exception."""
   38     def __init__(self, subject, html, txt):
   39         self.subject = subject
   40         self.html = html
   41         self.txt = txt
   42         BaseException.__init__(self, subject + ' ' + txt)
   43 
   44 
   45 class FormError(ValueError):
   46     """An 'expected' exception occurred during form parsing.
   47 
   48     That is, something we know can go wrong, and don't want to alarm the user
   49     with.
   50 
   51     We trap this at the user interface level and feed back a nice error to the
   52     user.
   53 
   54     """
   55     pass
   56 
   57 
   58 class SendFile(RoundupException):
   59     """Send a file from the database."""
   60 
   61 
   62 class SendStaticFile(RoundupException):
   63     """Send a static file from the instance html directory."""
   64 
   65 
   66 class SeriousError(RoundupException):
   67     """Raised when we can't reasonably display an error message on a
   68     templated page.
   69 
   70     The exception value will be displayed in the error page, HTML
   71     escaped.
   72     """
   73     def __str__(self):
   74         return """
   75 <html><head><title>Roundup issue tracker: An error has occurred</title>
   76  <link rel="stylesheet" type="text/css" href="@@file/style.css">
   77 </head>
   78 <body class="body" marginwidth="0" marginheight="0">
   79  <p class="error-message">%s</p>
   80 </body></html>
   81 """ % html_escape(self.args[0])
   82 
   83 # vim: set filetype=python sts=4 sw=4 et si :