Merge branch 'topic/SpecificExceptions' into develop

This commit is contained in:
Vincent Jacques
2013-04-22 22:23:04 +02:00
7 changed files with 86 additions and 5 deletions
+31 -3
View File
@@ -17,13 +17,41 @@
class GithubException(Exception):
"""
This class represents GithubExceptions as returned for example by http://developer.github.com/v3/todo
Error handling in PyGithub is done with exceptions. This class is the base of all exceptions raised by PyGithub.
Some other types of exceptions might be raised by underlying libraries, for example for network-related issues.
"""
def __init__(self, status, data):
Exception.__init__(self)
self.status = status
self.data = data
self.__status = status
self.__data = data
@property
def status(self):
"""
The status returned by the Github API
"""
return self.__status
@property
def data(self):
"""
The (decoded) data returned by the Github API
"""
return self.__data
def __str__(self):
return str(self.status) + " " + str(self.data)
class BadCredentialsException(GithubException):
"""
Exception raised in case of bad credentials (when Github API replies with a 401 or 403 HTML status)
"""
class UnknownObjectException(GithubException):
"""
Exception raised a non-existing object is requested (when Github API replies with a 404 HTML status)
"""