Skip to content
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

Display URL as part of HTTP error messages #2648

Merged
merged 1 commit into from
Jun 22, 2015

Conversation

msabramo
Copy link
Contributor

It seems convenient to include the URL in the error message in case you get an unexpected error.

E.g.:

In [1]: import requests

In [2]: resp = requests.get('http://www.google.com/eofdfdfdfdfd')

In [3]: resp
Out[3]: <Response [404]>

In [4]: resp.raise_for_status()
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
<ipython-input-4-00e7077cfb5b> in <module>()
----> 1 resp.raise_for_status()

/Users/marca/dev/git-repos/requests/requests/models.py in raise_for_status(self)
    835
    836         if http_error_msg:
--> 837             raise HTTPError(http_error_msg, response=self)
    838
    839     def close(self):

HTTPError: 404 Client Error: Not Found for url: http://www.google.com/eofdfdfdfdfd

It seems convenient to include the URL in the error message in case you
get an unexpected error.

E.g.:

    In [1]: import requests

    In [2]: resp = requests.get('http://www.google.com/eofdfdfdfdfd')

    In [3]: resp
    Out[3]: <Response [404]>

    In [4]: resp.raise_for_status()
    ---------------------------------------------------------------------------
    HTTPError                                 Traceback (most recent call last)
    <ipython-input-4-00e7077cfb5b> in <module>()
    ----> 1 resp.raise_for_status()

    /Users/marca/dev/git-repos/requests/requests/models.py in raise_for_status(self)
        835
        836         if http_error_msg:
    --> 837             raise HTTPError(http_error_msg, response=self)
        838
        839     def close(self):

    HTTPError: 404 Client Error: Not Found for url: http://www.google.com/eofdfdfdfdfd
@Lukasa
Copy link
Member

Lukasa commented Jun 22, 2015

Seems reasonable enough to me. I'm happy to take this. @sigmavirus24?

@sigmavirus24
Copy link
Contributor

Seems like a good UX improvement to me. 👍

sigmavirus24 added a commit that referenced this pull request Jun 22, 2015
Display URL as part of HTTP error messages
@sigmavirus24 sigmavirus24 merged commit f5dacf8 into psf:master Jun 22, 2015
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants