aboutsummaryrefslogtreecommitdiffstats
path: root/github3/errors.py
diff options
context:
space:
mode:
Diffstat (limited to 'github3/errors.py')
-rw-r--r--github3/errors.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/github3/errors.py b/github3/errors.py
index 09e616b..e96e2da 100644
--- a/github3/errors.py
+++ b/github3/errors.py
@@ -1,11 +1,10 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
-#
-# author: David Medina
import json
import github3.exceptions as exceptions
+
class GithubError(object):
""" Handler for API errors """
@@ -14,12 +13,15 @@ class GithubError(object):
self.status_code = response.status_code
try:
self.debug = self._parser.loads(response.content)
- except ValueError:
+ 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'))