mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-02 03:41:08 +00:00
Merge branch 'topic/SpecificExceptions' into develop
This commit is contained in:
+8
-1
@@ -96,9 +96,16 @@ class Requester:
|
||||
def __check(self, status, responseHeaders, output):
|
||||
output = self.__structuredFromJson(output)
|
||||
if status >= 400:
|
||||
raise GithubException.GithubException(status, output)
|
||||
raise self.__createException(status, output)
|
||||
return responseHeaders, output
|
||||
|
||||
def __createException(self, status, output):
|
||||
if status == 401 and output["message"] == "Bad credentials":
|
||||
return GithubException.BadCredentialsException(status, output)
|
||||
if status == 404 and output["message"] == "Not Found":
|
||||
return GithubException.UnknownObjectException(status, output)
|
||||
return GithubException.GithubException(status, output)
|
||||
|
||||
def __structuredFromJson(self, data):
|
||||
if len(data) == 0:
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user