~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to lib/common/cgirequest.py

  • Committer: mattgiuca
  • Date: 2008-03-05 05:32:22 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:649
lib/common/cgirequest.py: Added "message" arg to req.throw_error.
    Now just raises an exception instead of printing. This should
    be handled in the same way as errors in the main IVLE
    (bug added).

Show diffs side-by-side

added added

removed removed

Lines of Context:
242
242
        else:
243
243
            return sys.stdin.read(len)
244
244
 
245
 
    def throw_error(self, httpcode):
 
245
    def throw_error(self, httpcode, message):
246
246
        """Writes out an HTTP error of the specified code. Exits the process,
247
247
        so any code following this call will not be executed.
248
248
 
253
253
        httpcode: An HTTP response status code. Pass a constant from the
254
254
        Request class.
255
255
        """
256
 
        self.status = httpcode
257
 
        self.content_type = "text/html"
258
 
        # Emulate an Apache error
259
 
        self.write("""<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
260
 
<html><head>
261
 
<title>%d Error</title>
262
 
</head><body>
263
 
<h1>Error</h1>
264
 
<p>A %d error was triggered by a CGI app.</p>
265
 
</body></html>
266
 
""" % (httpcode, httpcode))
267
 
        # Exit the process completely
268
 
        self.flush()
269
 
        sys.exit(httpcode)
 
256
        raise common.util.IVLEError(httpcode, message)
270
257
 
271
258
    def throw_redirect(self, location):
272
259
        """Writes out an HTTP redirect to the specified URL. Exits the