-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Only return errors, without panics #439
Comments
Hi @agamb-cerebras, thanks for the report. go-mail does not use panic anywhere in the code, so that error must be coming from somewhere in the Go standard library. Could you share some code to reproduce, so I can have a look at what might be the root cause? |
Yes, it's not from within I'm going to add logging with my [fwiw, I suspect this happened with something like |
Btw. which version of go-mail are you using. I checked the stack trace and the lines reported do not match up with the current code. |
I did some digging in the textproto code and found the potential panic. It's issued in the End method of the sequencer. It panics if the sequencer id does not match the end id. This comes likely down to a concurrency issue. I assume it is a similar issue to #385. Given the code in the stacktrace I assume you are not using go-mail v0.6+ yet. The concurrency issue was fixed in v0.6.0 (PR #386). If this is the case, I suggest you update to the latest release and check if the panics still occur. |
Is your feature request related to a problem? Please describe.
Hi all,
I've been using the go-mail library and have found it very helpful.
However, I've encountered some scenarios where the library uses
panic
for errors that could potentially be handled gracefully by the calling code.This can lead to unexpected application termination (!)
As a result, I have to wrap calls with a
recover(...)
block. I feel the interface of the library should not push through panics this way, and should represent such states as new error codes instead.Here's an example of how this fails, when sending mail:
Describe the solution you'd like
I would prefer that this
recover(...)
logic was handled internally withingo-mail
, so that its interface can be used in a uniform idiomaticif ..., err := ...; err != nil ...
etc way.Of course, this is a matter of personal preference too, and if this has already been considered and rejected, please share the reason and close this out instead -- otherwise, please do consider adopting this approach.
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: