dotcloud/docker-py — pull request #38 by aanand (2013-09-03 17:42:05+00:00)
Title: Improvements to error reporting

- `APIError` class extends `HTTPError`
- Custom error string logic moved into `APIError.__init__()`
- Conveniences: `error.explanation`, `error.is_client_error()`, `error.is_server_error()`
- Strip trailing newline from explanation.
- Many methods were swallowing API errors - I've made sure we call `_raise_for_status()` everywhere it's needed.
- A couple of methods were doing their own, rather strange error handling (e.g. `history()` was raising `KeyError`). I've replaced those with `_raise_for_status()` as well.
- There was a redundant status check in `_result()` - `_raise_for_status()` is responsible for deciding whether or not to raise.