An exception that ends the request without producing an error response. When `Finish` is raised in a `RequestHandler`, the request will end (calling `RequestHandler.finish` if it hasn't already been called), but the error-handling methods (including `RequestHandler.write_error`) wil
| 2414 | |
| 2415 | |
| 2416 | class Finish(Exception): |
| 2417 | """An exception that ends the request without producing an error response. |
| 2418 | |
| 2419 | When `Finish` is raised in a `RequestHandler`, the request will |
| 2420 | end (calling `RequestHandler.finish` if it hasn't already been |
| 2421 | called), but the error-handling methods (including |
| 2422 | `RequestHandler.write_error`) will not be called. |
| 2423 | |
| 2424 | If `Finish()` was created with no arguments, the pending response |
| 2425 | will be sent as-is. If `Finish()` was given an argument, that |
| 2426 | argument will be passed to `RequestHandler.finish()`. |
| 2427 | |
| 2428 | This can be a more convenient way to implement custom error pages |
| 2429 | than overriding ``write_error`` (especially in library code):: |
| 2430 | |
| 2431 | if self.current_user is None: |
| 2432 | self.set_status(401) |
| 2433 | self.set_header('WWW-Authenticate', 'Basic realm="something"') |
| 2434 | raise Finish() |
| 2435 | |
| 2436 | .. versionchanged:: 4.3 |
| 2437 | Arguments passed to ``Finish()`` will be passed on to |
| 2438 | `RequestHandler.finish`. |
| 2439 | """ |
| 2440 | |
| 2441 | pass |
| 2442 | |
| 2443 | |
| 2444 | class MissingArgumentError(HTTPError): |