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
kontrol: change callback signature of WatchKites() #9
Comments
Another idea: What about leaving the error field to the user? In other words, I am talking about putting the error value into the result object (the only argument sent or received [which will always be a struct/object]). Example: {
"field0": "foo",
"field1": 1,
"error": {...}
} I think this makes more sense because not every function has to return an error. For example simple Add(int, int) function cannot return an error. However, we can make this a convention an check the error field at the library level automatically. Does that make sense? |
yes, sure |
actually, I'd rather nest the data one level deep: {
"result": {
"field0": "foo",
"field1": 1
},
// optionally
"error": {...}
} it gives us the possibility of adding meta-data at a later point, for example |
@fatih What's your opinion on this? |
another point: the application itself may provide an {
"result": {
"error": "some arbitrary property called 'error'"
"prop0": 42
}
// mutually exclusive, but not ambiguous
"error": {
"name": "ErrInvalidSession"
...
}
} |
I'm convinced. I will make the change and open a pull request. |
I'm confused with Chris's last example. How is that supposed to be simple from our current approach? There are two error fields. Is that example showing a wrong situation or current? Can you guys post two example JSON's, one which reflects the current on and one which is supposed to be. I don't want to introduce complex changes. |
The point with my last example is that we should have 1 top-level namespace with the result and error, rather than mixing the result into the same namespace as the error. The latter can cause an ambiguity if the result actually has a property called "error" |
It should pass a single JSON object with unordered
result
anderror
properties. See #8The text was updated successfully, but these errors were encountered: