emersion / go-smtp

📤 An SMTP client & server library written in Go
MIT License
1.72k stars 217 forks source link

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

Open kayrus opened 2 years ago

kayrus commented 2 years ago

There there is no way to catch errors, returned by handleConn method: https://github.com/emersion/go-smtp/blob/30169acc42e795e5d35ce901c8387950b103dfd9/server.go#L124

https://github.com/emersion/go-smtp/blob/30169acc42e795e5d35ce901c8387950b103dfd9/server.go#L128

emersion commented 2 years ago

How does net/http handle this?

kayrus commented 2 years ago

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

emersion commented 2 years ago

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

kayrus commented 2 years ago

BTW, I noticed more limitations in ErrorLog handler:

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.