Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Document HttpError with autodoc (#8338)

Adrianc6f8933dae58
diff --git a/docs/topics/spider-middleware.rst b/docs/topics/spider-middleware.rst
index f6bdb6383..4efb0197f 100644
--- a/docs/topics/spider-middleware.rst
+++ b/docs/topics/spider-middleware.rst
@@ -291,6 +291,12 @@ For more information see: `HTTP Status Code Definitions`_.
.. _HTTP Status Code Definitions: https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
+Responses whose status code your spider does not handle reach your errback as
+an :exc:`~scrapy.spidermiddlewares.httperror.HttpError` exception:
+
+.. autoexception:: scrapy.spidermiddlewares.httperror.HttpError
+ :members:
+
HttpErrorMiddleware settings
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/scrapy/spidermiddlewares/httperror.py b/scrapy/spidermiddlewares/httperror.py
index 94a480344..0df0bbc7c 100644
--- a/scrapy/spidermiddlewares/httperror.py
+++ b/scrapy/spidermiddlewares/httperror.py
@@ -25,10 +25,13 @@ logger = logging.getLogger(__name__)
class HttpError(IgnoreRequest):
- """A non-2xx response was filtered"""
+ """Raised by :class:`HttpErrorMiddleware` for a response whose status code
+ is not successful and that the spider does not handle itself.
+ """
def __init__(self, response: Response, *args: object, **kwargs: object):
- self.response = response
+ self.response: Response = response
+ """The response that was filtered out."""
super().__init__(*args, **kwargs)