Skip to content

net/http: error messages are not introspectable #9383

Closed
@lavalamp

Description

@lavalamp

I just reviewed a PR with the line case err.Error() == "http: can't write HTTP request on broken connection". That's brittle code, and it's hard to test in a way that ensures it stays in sync with any changes to the error message wording in net/http--but there's no way to improve upon it given the errors the http package emits.

Possible improments:

  • net/http could predeclare its errors
  • or make a custom error type

Any mechanism is fine as long as it lets the compiler check that people are referring to the error they intend to.

(I realize this is probably low priority.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions