-
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
proposal: errors: add new function Temporary(error) bool #37250
Comments
I was not familiar with the Go Proposal Process and wrongly opened a merge request. I leave it here for tracking. |
I don't know if you are aware of the errors.As function introduced in Go 1.13. It does something very similar and integrates well with the Unwraper interface. It would look like this:
Edited: calling Temporary method. And now it looks similarly as yours. |
Hi @D1CED Your code does a different thing. It checks that it is possible to convert error to the interface with Temporary but the goal is to call Temporary function if it does exist. |
There are semantic problems with Temporary that we have to work out first. It may be that we end up deprecating Temporary entirely. See #32463 for more discussion. |
Hi @rsc Thanks for the clarification. I totally agree that Temporary and Timeout both need a clear semantic, and I think this comment captures the essence of it from the pure pragmatic point of view: errors are values, and I may not know (care) meaning and origins of the error while I have a ready recipe to treat the error programmatically. Even if Temporary and Timeout emerged solely as a mechanism to handle Linux syscalls, there is a demand for them outside of the Go standard library. The possible implementation can be a third-party package but such implementation:
I also like the idea to have these mechanisms built into the standard go library because it shifts responsibility towards the library creators (more experienced go programmers). Even though the particular implementation of the theoretical |
This should probably be on hold until we figure out whether Temporary disappears entirely. But right now we are taking a bit of a hiatus from error handling. |
Temporary was deprecated in #45729 , I think this can be declined? |
Moving back to Active to give people a chance to object, but in general this seems likely to be declined. |
Based on the discussion above, this proposal seems like a likely decline. |
No change in consensus, so declined. |
Good day.
This is proposal to add the Temporary function into errors package. I tend to rewrite it over and over again in every project.
Possible implementation:
Mainly, this function will be used in conjunction with the net package.
Nevertheless, I think Temporary function belongs to the erros package, in this case user code and other packages may follow the same convention.
The main reason for adding a new function into the go standard library is to promote the "Temporary" concept.
If there's no common mechanism to determine if operation can be retried then error handling becomes more intricate.
Also, I think the function is in line with the "errors are values."
The text was updated successfully, but these errors were encountered: