diff options
author | 2012-02-03 02:59:53 +0100 | |
---|---|---|
committer | 2012-02-03 02:59:53 +0100 | |
commit | ae1c3c06c47866c8f392d05c63f597d71cebd691 (patch) | |
tree | 6543c55e2210bd91f59124785200d1fbfb6be872 /github3/errors.py | |
parent | Update setup.py (diff) | |
download | python-github3-ae1c3c06c47866c8f392d05c63f597d71cebd691.tar.xz python-github3-ae1c3c06c47866c8f392d05c63f597d71cebd691.zip |
Reset project
Diffstat (limited to 'github3/errors.py')
-rw-r--r-- | github3/errors.py | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/github3/errors.py b/github3/errors.py deleted file mode 100644 index e96e2da..0000000 --- a/github3/errors.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -import json -import github3.exceptions as exceptions - - -class GithubError(object): - """ Handler for API errors """ - - def __init__(self, response): - self._parser = json - self.status_code = response.status_code - try: - self.debug = self._parser.loads(response.content) - except (ValueError, TypeError): - self.debug = {'message': response.content} - - def error_400(self): - return exceptions.BadRequest("400 - %s" % self.debug.get('message')) - - def error_401(self): - return exceptions.Unauthorized("401 - %s" % self.debug.get('message')) - - def error_404(self): - return exceptions.NotFound("404 - %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 exceptions.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() |