diff options
author | 2012-02-03 14:45:32 +0100 | |
---|---|---|
committer | 2012-02-03 14:46:54 +0100 | |
commit | f01bc94a33d8644da65b5fa895c222e9ee057b50 (patch) | |
tree | 3bfc837901a54f97a30f1d24431d8322906de192 /github3/errors.py | |
parent | Pypi environment by setuptools (diff) | |
download | python-github3-f01bc94a33d8644da65b5fa895c222e9ee057b50.tar.xz python-github3-f01bc94a33d8644da65b5fa895c222e9ee057b50.zip |
Fix imports to new environment
Absolute imports as PEP8 tells
Diffstat (limited to 'github3/errors.py')
-rw-r--r-- | github3/errors.py | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/github3/errors.py b/github3/errors.py deleted file mode 100644 index 0d58c16..0000000 --- a/github3/errors.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -import json - - -class BadRequest(Exception): - pass - - -class UnprocessableEntity(Exception): - pass - - -class GithubError(object): - """ Handler for API errors """ - - def __init__(self, response): - self.response = response - self.status_code = response.status_code - try: - self.debug = json.loads(response.content) - except (ValueError, TypeError): - self.debug = {'message': response.content} - - def error_400(self): - return BadRequest("400 - %s" % self.debug.get('message')) - - def error_422(self): - errors = self.debug.get('errors') - if errors: - errors = ['{resource}: {code} => {field}'.format(**error) - for error in errors] - return UnprocessableEntity( - '422 - %s %s' % (self.debug.get('message'), errors)) - - def process(self): - raise_error = getattr(self, 'error_%s' % self.status_code, False) - if raise_error: - raise raise_error() - self.response.raise_for_status() |