Several of the HTTPError subclasses had incorrect or malformed docstrings; these were fixed and type annotations were added in support of sphinx.
29 lines
864 B
ReStructuredText
29 lines
864 B
ReStructuredText
.. _errors:
|
|
|
|
Error Handling
|
|
==============
|
|
|
|
When something goes horribly (or mildly) wrong, you *could* manually set the
|
|
error status, appropriate response headers, and even an error body using the
|
|
``resp`` object. However, Falcon tries to make things a bit easier by
|
|
providing a set of exceptions you can raise when something goes wrong. In fact,
|
|
if Falcon catches any exception your responder throws that inherits from
|
|
``falcon.HTTPError``, the framework will convert that exception to an
|
|
appropriate HTTP error response.
|
|
|
|
You may raise an instance of ``falcon.HTTPError`` directly, or use any one
|
|
of a number of predefined error classes that try to be idiomatic in
|
|
setting appropriate headers and bodies.
|
|
|
|
Base Class
|
|
----------
|
|
|
|
.. autoclass:: falcon.HTTPError
|
|
:members:
|
|
|
|
Predefined Errors
|
|
-----------------
|
|
|
|
.. automodule:: falcon.exceptions
|
|
:members:
|