mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Merge branch 'topic/SpecificExceptions' into develop
This commit is contained in:
@@ -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)
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user