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

better http error caching when downloading #212

Merged
merged 1 commit into from Nov 26, 2018

Conversation

peterbe
Copy link
Owner

@peterbe peterbe commented Nov 26, 2018

It's "dangerous" to assume that every requests.get(url) works out perfectly.
This PR makes that a bit more explicit and louder if it does fail to download a URL correctly.

Sample traceback:

Traceback (most recent call last):
  File "dummy.py", line 31, in <module>
    print(premailer.transform(html, cssutils_logging_level=logging.ERROR))
  File "/Users/peterbe/dev/PYTHON/premailer/premailer/premailer.py", line 670, in transform
    return Premailer(**kwargs).transform(html, pretty_print=pretty_print)
  File "/Users/peterbe/dev/PYTHON/premailer/premailer/premailer.py", line 374, in transform
    css_body = self._load_external(href)
  File "/Users/peterbe/dev/PYTHON/premailer/premailer/premailer.py", line 551, in _load_external
    css_body = self._load_external_url(url)
  File "/Users/peterbe/dev/PYTHON/premailer/premailer/premailer.py", line 537, in _load_external_url
    response.raise_for_status()
  File "/Users/peterbe/virtualenvs/premailer/lib/python3.6/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://www.peterbe.com/static/css/base.min.79787297dbf5.csxxxxs

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling cff3395 on better-http-error-caching-when-downloading into 03e8848 on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling cff3395 on better-http-error-caching-when-downloading into 03e8848 on master.

@peterbe peterbe merged commit 2a56425 into master Nov 26, 2018
@peterbe peterbe deleted the better-http-error-caching-when-downloading branch November 26, 2018 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants