-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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
Proposal: flag.failf should return an error with Cause() error #18303
Comments
@bradfitz Thanks for the quick response! (@everyone) Are there any reasons against exposing From skimming the other discussions, I get the sense that the Go team wants to hold off on refactoring any error provenance in the standard library until it's fixed everywhere, but for a standard library of this size, I don't think that's practical. Instead, I suggest analyzing what makes sense on a case-by-case basis (e.g. this issue), incrementally introducing non-breaking improvements, and shaping a "standard" around what proves worthy in Go2. |
To clarify, I don't mean we should add something just because it has no downsides-- that's a recipe for creating a mess of a standard library... but I want to focus on what's wrong with this proposal (e.g. doesn't provide enough value to go in stdlib, encourages bad design, not readable, etc.) rather than the error handling everywhere in the standard library. |
What do you mean exposing? If this method already exists on the type then there is nothing to do. If the method does not exist, then that's a bigger ask and out of scope for Go 1.8. |
The challenge is that this proposal is trying to add a method to a value of type |
I was suggesting that the flag package returns a struct that implements non-standard
It can go in docs as well?
Agreed that this is not the place to talk about Curious- If this is not the right place, what is the right place? I understand that this may be out of scope for Go 1.8, but I'd still like to propose it... maybe for 1.9? |
Unless and until this becomes an accepted soft standard for errors, we should probably not start adding it to the standard library throughout, and we also shouldn't add it piecemeal. Like @bradfitz said above, the situation is far from settled. Declining until that changes. (And if it does change, and we decide that this is something we want everywhere, we'll probably just do it, without needing to reopen this proposal.) |
@rsc I understand your concern about adding this piecemeal. My proposal is that the Go standard library should return a struct that satisfies What does the Go team think of this conceptually? I understand that, in the end, this is out of my control, but what's missing / how can I help convince the Go team that this is important? |
Without this feature, stdlib expects users to either
|
I understand the general problem. We should be sure of how we want to solve that before we start editing package flag. Maybe 'Cause() error' is not the solution. Until we know the solution, we shouldn't add it to package flag. |
@rsc Got it.
Where does discussion about that take place? What are next steps? |
To expand, I think it's important to have a place for open discussion about error handling in the standard library since the Go team recognizes the general problem but isn't sure what the right solution is yet. As I mentioned here, one exists for generics, which is in a similar boat, except almost certainly requires large language changes and breaking changes in general. I was hoping this issue would serve that purpose, but I'd be happy to open another one (or a mailing list thread, etc.)
^ The aforementioned issue would be a good place for pros/cons of |
I don't think we're ready to have a conversation about errors right now. It's on my list for next year, hopefully before the summer. |
Alrighty |
It would be very nice if
flag.failf
returned an error with aCause()
so that if you define your ownflag.Value
-implementing type, you don't lose context on errors you return out of itsSet
function here.I would definitely be willing to open a patch if whoever's in charge agrees on the design. :)
The text was updated successfully, but these errors were encountered: