Skip to content
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

text/template: distinguish write errors from template errors #11898

Closed
robpike opened this issue Jul 28, 2015 · 2 comments
Closed

text/template: distinguish write errors from template errors #11898

robpike opened this issue Jul 28, 2015 · 2 comments
Milestone

Comments

@robpike
Copy link
Contributor

robpike commented Jul 28, 2015

See #11845

The template package is being blamed (unfairly in my opinion) for issues around SIGPIPE, but there is a fair point to be made: The template package should make it easy to distinguish errors caused by execution from errors caused by I/O. The former is a programming problem that should be fixed; the latter is just bad luck. A conscientious program (like cmd/go) could act differently in the two cases.

@bradfitz
Copy link
Contributor

The template package should make it easy to distinguish execution errors caused by execution from errors caused from I/O.

Not just the template package, though. I needed this distinction in net/http the other day, and I always finding myself writing little helper functions like,

func isNetWriteError(err error) bool {
    switch e := err.(type) {
    case *url.Error:
        return isNetWriteError(e.Err)
        case *net.OpError:
        return e.Op == "write"
        default:
        return false
    }
}

Maybe we put some of those style helpers in a common package?

@gopherbot
Copy link

CL https://golang.org/cl/13953 mentions this issue.

@golang golang locked and limited conversation to collaborators Sep 4, 2016
@rsc rsc unassigned robpike Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants