Skip to content

all: document that error.Unwrap was added in 1.13 #36781

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

Closed
rillig opened this issue Jan 26, 2020 · 2 comments
Closed

all: document that error.Unwrap was added in 1.13 #36781

rillig opened this issue Jan 26, 2020 · 2 comments
Labels
Documentation Issues describing a change to documentation. FrozenDueToAge

Comments

@rillig
Copy link
Contributor

rillig commented Jan 26, 2020

What version of Go are you using?

1.12 and 1.13

What did you do?

To classify network errors, I used the Unwrap method:

func classifyNetworkError(err error) string {
	cause := err
	for {
		type nested interface{ Unwrap() error }
		unwrap, ok := cause.(nested)
		if !ok {
			break
		}
		cause = unwrap.Unwrap()
	}
	return cause.Error()
}

The Unwrap method comes handy, I just wondered why there is no predefined interface like NestedError for that method.

I got strange differences between Go 1.12 and Go 1.13, which I couldn't explain. In Go 1.12 the errors were not unwrapped at all.

What did you expect to see?

The Unwrap in all error types are clearly documented as "added in 1.13".

What did you see instead?

Nothing.

References

@gopherbot gopherbot added the Documentation Issues describing a change to documentation. label Jan 26, 2020
@rillig rillig changed the title net/url: document that error.Unwrap was added in 1.13 all: document that error.Unwrap was added in 1.13 Jan 26, 2020
@smasher164
Copy link
Member

I looked through the Unwrap methods on exported types, listed here (https://golang.org/search?q=Unwrap), and notice that they all list "1.13" on godoc. What additional documentation do you have in mind here?

@rillig
Copy link
Contributor Author

rillig commented Jan 27, 2020

Oops, I must have missed that information. Or, which is more likely, I trusted my IDE to show me all relevant information, which it didn't.

When I looked at the implementation of the various Unwrap methods, I didn't see any version being mentioned. Therefore I thought it was missing. In addition, even after I found the commit that added the Unwrap methods, that commit did not add the entries to api/go1.13.txt, which I would have expected.

With all this additional information, the golang project is fine. I'll tell JetBrains to improve their IDE by marking the API level of each definition. Thanks for the help.

@rillig rillig closed this as completed Jan 27, 2020
@golang golang locked and limited conversation to collaborators Jan 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation Issues describing a change to documentation. FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

3 participants