Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/scrapy/exceptions.py: 79%
28 statements
« prev ^ index » next coverage.py v7.4.1, created at 2024-02-07 06:38 +0000
« prev ^ index » next coverage.py v7.4.1, created at 2024-02-07 06:38 +0000
1"""
2Scrapy core exceptions
4These exceptions are documented in docs/topics/exceptions.rst. Please don't add
5new exceptions here without documenting them there.
6"""
7from typing import Any
9# Internal
12class NotConfigured(Exception):
13 """Indicates a missing configuration situation"""
15 pass
18class _InvalidOutput(TypeError):
19 """
20 Indicates an invalid value has been returned by a middleware's processing method.
21 Internal and undocumented, it should not be raised or caught by user code.
22 """
24 pass
27# HTTP and crawling
30class IgnoreRequest(Exception):
31 """Indicates a decision was made not to process a request"""
34class DontCloseSpider(Exception):
35 """Request the spider not to be closed yet"""
37 pass
40class CloseSpider(Exception):
41 """Raise this from callbacks to request the spider to be closed"""
43 def __init__(self, reason: str = "cancelled"):
44 super().__init__()
45 self.reason = reason
48class StopDownload(Exception):
49 """
50 Stop the download of the body for a given response.
51 The 'fail' boolean parameter indicates whether or not the resulting partial response
52 should be handled by the request errback. Note that 'fail' is a keyword-only argument.
53 """
55 def __init__(self, *, fail: bool = True):
56 super().__init__()
57 self.fail = fail
60# Items
63class DropItem(Exception):
64 """Drop item from the item pipeline"""
66 pass
69class NotSupported(Exception):
70 """Indicates a feature or method is not supported"""
72 pass
75# Commands
78class UsageError(Exception):
79 """To indicate a command-line usage error"""
81 def __init__(self, *a: Any, **kw: Any):
82 self.print_help = kw.pop("print_help", True)
83 super().__init__(*a, **kw)
86class ScrapyDeprecationWarning(Warning):
87 """Warning category for deprecated features, since the default
88 DeprecationWarning is silenced on Python 2.7+
89 """
91 pass
94class ContractFail(AssertionError):
95 """Error raised in case of a failing contract"""
97 pass