dstufft/slumber — pull request #78 by andymccurdy (2013-08-21 22:25:44+00:00)
Title: create a specialized error for 404s

NOTE: If #77 is accepted, I'm happy to merge this code with that one.

A missing object on a resource is a common error. Often times your app
will want to handle this case differently than other errors. Currently,
you have to catch the exception, test the response.status_code, and
then re-raise if it's not 404. e.g.,

```python
api = slumber.API(...)
try:
api.resource(some_id).get()
except slumber.exceptions.HttpClientError as e:
if e.resp.status_code == 404:
# do something 404-specific, perhaps raising a Http404 in Django
else:
raise # re-raise the original exception
```

This patch creates a new error (Http404Error) that subclasses
HttpClientError. It makes the use case much easier on users:

```python
api = slumber.API(...)
try:
api.resource(some_id).get()
except slumber.exceptions.Http404Error:
# do something 404-specific
```