-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
errors: eliminate skip argument to Caller #30809
Comments
I agree that skip counts are fragile and hard to use, but before I can support this proposal, I'd love to see a concrete proposal for how they might be eliminated. In my experience, it's pretty common to define a helper function that wraps fmt.Errorf, making the information on the caller of fmt.Errorf mostly noise, but how could the runtime "know" that the helper function is just that, and not important business logic that justifies that caller info? |
I personally like the I don't like this idea a whole lot, but we could have a global in errors that works like testing.T. Then you call I'd love to hear other concrete proposals. |
The nuclear option is to just get rid of the stack information, at least initially. It is (imo!) the least interesting/useful part of the proposal. It's also the part with the thorniest API/implementation issues (cf. DeepEquals). |
The approach taken by Perhaps some sort of |
(I should add: historically this is one of the key differences between macros and functions. Essentially, you're asking for the ability to define a function to have the behavior of a hygienic macro.) |
I suppose the question then is: would it be acceptable not to show that frame in a panic traceback stack too, should the error-creating function were to crash? (for the record, in the context of tests, |
I don't see how I agree that frame skip counts are not the kindest of APIs, but we need a concrete, viable counterproposal if we are to drop them. Having no control over skips seems far too limiting. One possibility might be to have just two constructor functions, corresponding to |
Given that there's no |
This discussion has been happening in CLs and the umbrella issue. Moving it to its own issue for focused discussion.
APIs that ask the caller to pass a number of frames to skip are fragile and hard to use. We should eliminate the skip argument and find another way to allow people to get the expressivity they need (if in fact they need it).
cc @jba @neild @mpvl @davecheney
The text was updated successfully, but these errors were encountered: