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
+8 -1
View File
@@ -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