Closed wneessen closed 1 year ago
Merging #91 (5897bdd) into main (f454ae8) will increase coverage by
0.02%
. The diff coverage is78.81%
.
@@ Coverage Diff @@
## main #91 +/- ##
==========================================
+ Coverage 83.12% 83.15% +0.02%
==========================================
Files 14 15 +1
Lines 1452 1549 +97
==========================================
+ Hits 1207 1288 +81
- Misses 170 186 +16
Partials 75 75
Impacted Files | Coverage Δ | |
---|---|---|
client_119.go | 54.94% <54.90%> (-0.80%) |
:arrow_down: |
msg.go | 86.54% <90.00%> (+0.05%) |
:arrow_up: |
senderror.go | 98.24% <98.24%> (ø) |
|
client.go | 78.04% <0.00%> (ø) |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
@iwittkau thanks for comments and review. Appreciated!
This PR introduces the
SendError
type which implements the error interface as solution for #90.A new
senderror
field has been added to theMsg
as well, so introduce this type to it.I've also added different error variables that indicate the different things that can go wrong during mail delivery. These variables can be checked for, for each
Msg
using theerrors.Is
anderrors.As
methods. Additionally, theSendError
has aisTemp
field that indicates if the delivery error is of temporary nature and can be accessed via theSendError.IsTemp()
method.The
Error()
method ofSendError
will return a detailed error string on why theMsg
could not be delivered.Additionally,
HasSendError()
,SendErrorIsTemp()
andSendError()
methods have been added toMsg
. WhileHasSendError()
simply returns a bool in case aMsg
failed during delivery andSendErrorIsTemp()
returns true if it's a temporary error, theSendError()
will return the fullSendError
error interface.As proposed by @iwittkau the
SendError
type has aIsTemp()
method as well indicating to the user if the delivery error is retryable or not.As suggested, we want to use it in the error response from the Client functions like
Send
orDialAndSend
we need to return theSendError
type not only as part of the*Msg
but also as return value for these methods. Hence, the changes made for #85 have been overhauled to return the new error type instead. In the pre Go1.20 version of theSend()
method we need to return an accumulated version of theSendError
type, since we don't haveerrors.Join()
and therefore, if more than one error occurred during the delivery we return an ambiguous error reason since we can't tell which of the captured errors is main error. For more details the user can always check the*Msg.SendError