New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to work with the GithubException object #152
Comments
This is the right track indeed. Here are a few remarks. You're right about So, whenever the Github API v3 returns a HTTP status above 400, I raise a Checking the Github API v3 documentation today, I see a few words about errors: http://developer.github.com/v3/#client-errors but in fact there are more possible errors. For example, 404 errors for non-existing objects, 401 for bad authentication, etc. So, what I can do now that I know the errors a bit more is to create sub-classes of I will do that in version 1.14.0 and take this as an opportunity to document it in http://jacquev6.github.com/PyGithub/. |
I will do that in branch |
This sounds terrific. Again, thanks for all of your hard work, and On Thu, Mar 28, 2013 at 12:59 PM, Vincent Jacques
Phill Conrad, Lecturer (SOE)*, Dept. of Computer Science pconrad@cs.ucsb.edu, www.cs.ucsb.edu/~pconrad*SOE: a UC teaching faculty appointment, corresponding in rank and job |
Thanks \o/ It's always very nice to ear a satisfied client! |
Yes, I think I shall give you a raise---double the salary I'm paying you On Thu, Mar 28, 2013 at 1:33 PM, Vincent Jacques
Phill Conrad, Lecturer (SOE)*, Dept. of Computer Science pconrad@cs.ucsb.edu, www.cs.ucsb.edu/~pconrad*SOE: a UC teaching faculty appointment, corresponding in rank and job |
Huhu, that would be both my biggest and smallest raise ever! |
Note to myself:
|
Part of this issue was deliver in 1.14.0, but I keep it for version 1.15.0 to add a few other specific exception types. |
New specific exception to create: HTTP 403 "bad user agent" (see #160) |
I'm closing this issue now, but I will continue to add specific types of exception when I encounter them. |
Hi, github.GithubException.BadCredentialsException: 401 {'message': 'Bad credentials', 'documentation_url': 'https://developer.github.com/v3'} Now I i try to access it directly I get the following error:
How can I catch this specific exception and not only a general githubexception? |
@NicoHood use |
GithubException is a class as well as a module, the full module path to the class is github.GithubException.GithubException, which you can't import BadCredentialsException from. All of the exceptions are exported via github, so |
I have a question about how to work with the GithubException object
Sample Code:
try:
team = org.create_team(teamName,
[],
"push");
except GithubException as e:
print (e)
When I print (e) I get:
What I'd like to be able to do is see the list of attributes and member functions of the GithubException object so that I can pull out various stuff to check for particular events... but I can'f find this in the documentation for the PyGithub API. Maybe I just need to understand better the relationship between the PyGithub API and the underlying github RESTful API.
From the source, it appears that there are two properties of the GithubException object:
https://github.com/jacquev6/PyGithub/blob/master/github/GithubException.py
and putting that together with the output, it appears the 422 is the status (perhaps returned by the API?), and the data is a dictionary object (perhaps an encoding of the JSON that got returned?) but these are only guesses.
It appears that the only place GithubException occurs in the source is in Requester.py---and this tends to confirm my guesses.
Is there somewhere in the documentation for the github API itself where one can find the keys that one would expect to find in the JSON object, i.e. in this case "message", "errors", and then within "errors", "field", "code", "and "resource"?
From trial and error guesswork, I settled on code like this, but this feels "hacky---I'd be more comfortable if I knew whether I was doing this right...
Am I on the right track?
The text was updated successfully, but these errors were encountered: