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
Assignees
Milestone

Comments

@robpike
Copy link
Contributor

@robpike 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

@bradfitz bradfitz commented Jul 28, 2015

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

@gopherbot gopherbot commented Aug 27, 2015

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

@robpike robpike closed this in be33e20 Aug 27, 2015
@golang golang locked and limited conversation to collaborators Sep 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.