-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List of documented exceptions doesn't match reality / unused URLRequired
exception
#6877
Comments
Thanks for reporting, if you could submit a PR fixing the issue it would be appreciated. |
The fix itself for this is probably trivial, at least for the "undocumented exceptions" part (adding a few
|
Removing the unused URLRequired from the docs is reasonable. The current listing is misleading. The exception itself needs to be left in the code for backwards compat. We could potentially make a note in the docstring it's deprecated if we're positive it's unused. For intended workflow, this is in the linked docs which is the recommendation for exception handling within the library.
Most of the unlisted exceptions are not particularly useful for application control flow. If there are specific ones users think are needed, we're happy to review those on a case-by-case basis. |
The documentation lists a relatively small list of exceptions, among them:
which would imply that passing an invalid URL raises
URLRequired
. However, that exception is actually dead code and not raised anywhere ever since ab27027 in 2012. Instead, with requests 2.32.3, invalid URLs raise something likeMissingSchema
,InvalidSchema
orInvalidURL
, none of which are documented.Looking at exceptions.py, there seem to be various other undocumented exceptions in there:
class InvalidJSONError(RequestException):
(onlyJSONDecodeError
which inherits from it)class ProxyError(ConnectionError):
class SSLError(ConnectionError):
class ConnectTimeout(ConnectionError, Timeout):
(Timeout
is documented)class ReadTimeout(Timeout):
(Timeout
is documented)class MissingSchema(RequestException, ValueError):
class InvalidSchema(RequestException, ValueError):
class InvalidURL(RequestException, ValueError):
class InvalidHeader(RequestException, ValueError):
class InvalidProxyURL(InvalidURL):
class ChunkedEncodingError(RequestException):
class ContentDecodingError(RequestException, BaseHTTPError):
class StreamConsumedError(RequestException, TypeError):
class RetryError(RequestException):
class UnrewindableBodyError(RequestException):
(Some of those might be internal, or considered not worth documenting since they can be caught by
except ValueError:
. However, even e.g. Errors and Exceptions or the reference docs don't seem to point out that either.The text was updated successfully, but these errors were encountered: