-
Notifications
You must be signed in to change notification settings - Fork 16
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
Improve Error handling #166
Comments
@dworthen I agree we should transition to a uniform result structure. I've done this in #167 In your example, Currently, Here are some example outputs:
Let me know if this looks good to you for a start. Would you want to add anything else? |
@dworthen #167 resolves the issue with returning a structured result. See the updated PR description for the details #167 Next is your request to return more informative error messages and to handle some circumstances in the backend. For this one, in general, feel free to file individual issues every time you identify an applicable situation. So far, based on this issue, I created: |
@dworthen I released the structured result output in https://github.com/gov4git/gov4git/releases/tag/v2.0.4 |
Thanks @petar. I think this is a good start. One thing I like about the idea of status codes is fine grain classification of errors which then gives us better recoverability and reporting capabilities. For example, if a user is not a member of a community and has not made a join request then I can try to recover from that state by opening a join request and redirecting the user to the join request status page where they may view the request status. In other cases I may just want to present the error message instead of trying to recover such as in the case the user has made a join request but has been denied. Here are some example error states that come to mind.
|
A few more error responses
Sometimes there is a delay in creating things in github and them showing up in the API/protocol. For example when I start with a brand new user and log in for the first time it creates their personal identity repos and initializes them with the init id command. I can view the repo in GitHub but Gov4Git commands will fail with a stack trace indicating it cannot find the public identity repo. That "repository not found". So for API requests that may have a delay it would be great to get an error stating the problem but also indicating that if you are a new user it may take some time for the system to sync and to try again later. |
Currently, running g4g cli commands can fail in predictable ways but tends to throw stack traces to stderr that are unintuitive and hard to recover from. Examples of some known exceptions is trying to vote when a user is not a member. In this case I would expect the CLI to repor that user X is not a member of community Y and therefore cannot vote. Another example is trying to deploy a gov4git community for a project url that already has a deployed gov4git community. In that case I would expect the response to indicate that the community already exists and is skipping the deployment. With the current CLI, the approach is try to run a g4g command and if it fails, try running separate validation logic such as checking the community exists and checking user exists and checking user is member through various commands to try and determine the cause of error and recover.
I think we can take some inspiration from HTTP APIs such as GitHub where known errors are returned in the stdout response and only unknown, unrecoverable errors are thrown to stderr. This would require wrapping our current stdout outputs indicating the response status (like a status code) along wiht the response.
For example, a successful
panorama
command might returnand a caught error might return
The text was updated successfully, but these errors were encountered: