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

server: handleConn's return error cannot be catched #167

Open
kayrus opened this issue Nov 10, 2021 · 4 comments
Open

server: handleConn's return error cannot be catched #167

kayrus opened this issue Nov 10, 2021 · 4 comments
Labels

Comments

@kayrus
Copy link
Contributor

kayrus commented Nov 10, 2021

There there is no way to catch errors, returned by handleConn method:

go s.handleConn(newConn(c, s))

func (s *Server) handleConn(c *Conn) error {

@emersion
Copy link
Owner

How does net/http handle this?

@kayrus
Copy link
Contributor Author

kayrus commented Nov 10, 2021

@emersion net/http's serve method doesn't return err, it passes it to the ErrorLog handler.

@emersion
Copy link
Owner

emersion commented Nov 10, 2021

Hm, and ErrorLog seems to be used for many kinds of failures, both server-side panics, TLS handshakes and handler errors.

@kayrus
Copy link
Contributor Author

kayrus commented Nov 23, 2021

BTW, I noticed more limitations in ErrorLog handler:

  • it doesn't preserve the original err, it contains only the error text ("%v", err instead of the "%w", err).
  • it doesn't preserve the TCP connection state c.State()

If I'd have a logging struct satisfying the ErrorLog interface, I'd like to have an ability to get the original error and the TCP connection state data.

drdaeman added a commit to drdaeman/go-smtp that referenced this issue Mar 10, 2022
Now Serve does not exit on non-fatal errors from Accept.
This resolves emersion#180

It also logs handleConn errors to the ErrorLog - which is a partial
improvement for emersion#167
emersion pushed a commit that referenced this issue Mar 15, 2022
Now Serve does not exit on non-fatal errors from Accept.
This resolves #180

It also logs handleConn errors to the ErrorLog - which is a partial
improvement for #167
@emersion emersion changed the title core: handleConn's return error cannot be catched server: handleConn's return error cannot be catched Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants