Created
November 4, 2010 20:51
-
-
Save dvogel/663167 to your computer and use it in GitHub Desktop.
Tornado RequestHandler.send_error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def send_error(self, status_code=500, **kwargs): | |
"""Sends the given HTTP error code to the browser. | |
We also send the error HTML for the given error code as returned by | |
get_error_html. Override that method if you want custom error pages | |
for your application. | |
""" | |
if self._headers_written: | |
logging.error("Cannot send error response after headers written") | |
if not self._finished: | |
self.finish() | |
return | |
self.clear() | |
self.set_status(status_code) | |
message = self.get_error_html(status_code, **kwargs) | |
self.finish(message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment