Comments (2)
@dworthen as I look at the code, I see that the code already produces an error amounting to "user X is not a member of community Y", specifically this one https://github.com/gov4git/gov4git/blob/v2/proto/ballot/ballotpolicies/sv/verify.go#L27
Was your issue simply that you couldn't parse it out when it's mixed in with the stack trace, or are you not able to observe this error at all?
Or, is your request to have an error message that literally spells out "user X is not a member of community Y". If this was your intention (I am guessing not), I want to point out that the errors returned from the backend should be viewed as an interface between the backend and the frontend — they are not generally targeted for the end-user to see. The key thing for us would be to have a backend/frontend contract that fixes the message format for this specific error, so that the frontend can always recognize it and present meaningful options to the user.
If you think that a text message is an awkward datamodel for communicating errors (e.g. some errors may want to communicate parameters), then I can produce structured errors which will appear in the cli result structure under the field "error" in the form of a JSON structure. Example:
{
"status": "error",
"msg": "voter is not in the community",
"error": {
"voter_not_a_member": true,
"voter_repo": "https://github.com/xxx/gov4git-identity-public"
}
}
Let me know what you think.
from gov4git.
I think the general goal is to have a general format for responses that incorporates the possibility of errors in a way that is easy to parse. Stack traces and plain strings returned from the CLI are hard and brittle to parse. A string without a label or context is hard to know if it is an error or the expected response. Stack traces are just problematic to parse programmatically and reliably and there can be multiple stack traces with varying lengths or thrown from different spots that essentially mean the same thing such as user not found. In Gov4Git's case a lot of stack traces end with "File not found" which can mean a whole variety of things.
I am fine with the msg field for reporting errors. I am not sure about the error object. I am not a fan of dictionaries with unknown keys and would prefer typed objects of known keys. That makes it easier to parse and understand. In #166 I also suggested using something like a status field much like HTTP status codes. Something that can either be a field enum or number. Something that gives us fine grain labeling and classification of errors without having to rely on the error message which may change overtime or be brittle to parse and rely on.
from gov4git.
Related Issues (20)
- put README.md in the governance and identity public/private repos with links to gov4git
- display accumulated bounties/rewards on issues/PRs in the github ui
- display accumulated bounties/rewards on issues/PRs in the desktop app HOT 1
- versioning protocol, client and app + design migration workflows
- automate end-to-end tests
- cron job error: ModuleNotFoundError: No module named 'matplotlib' HOT 4
- Expired CI PAT token
- Improve Error handling HOT 5
- differentiate `community exists` from `repo exists` errors when deploying
- Site isn't working HOT 1
- Breaking Changes in 2.1.1 HOT 1
- Gov4Git community dashboard
- I'd like to join this project's community HOT 2
- Discord Link Broken HOT 1
- issue to BastinJafari HOT 1
- issue to petar HOT 1
- introduce status codes for error conditions HOT 1
- fund the matching pool HOT 1
- I'd like to join this project's community HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gov4git.