mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 13:50:49 +01:00
Make golangci-lint happy by using errors.As
instead of using type assertion on error (which can fail on wrapped errors)
This commit is contained in:
parent
78df991399
commit
f6709e90cd
2 changed files with 9 additions and 8 deletions
8
msg.go
8
msg.go
|
@ -969,11 +969,11 @@ func (m *Msg) HasSendError() bool {
|
||||||
// SendErrorIsTemp returns true if the Msg experienced an error during the message delivery and the
|
// SendErrorIsTemp returns true if the Msg experienced an error during the message delivery and the
|
||||||
// corresponding error was of temporary nature and should be retried later
|
// corresponding error was of temporary nature and should be retried later
|
||||||
func (m *Msg) SendErrorIsTemp() bool {
|
func (m *Msg) SendErrorIsTemp() bool {
|
||||||
e, ok := m.sendError.(*SendError)
|
var e *SendError
|
||||||
if !ok {
|
if errors.As(m.sendError, &e) {
|
||||||
return false
|
return e.isTemp
|
||||||
}
|
}
|
||||||
return e.isTemp
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendError returns the senderror field of the Msg
|
// SendError returns the senderror field of the Msg
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
package mail
|
package mail
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -94,11 +95,11 @@ func (e *SendError) Error() string {
|
||||||
|
|
||||||
// Is implements the errors.Is functionality and compares the SendErrReason
|
// Is implements the errors.Is functionality and compares the SendErrReason
|
||||||
func (e *SendError) Is(et error) bool {
|
func (e *SendError) Is(et error) bool {
|
||||||
t, ok := et.(*SendError)
|
var t *SendError
|
||||||
if !ok {
|
if errors.As(et, &t) {
|
||||||
return false
|
return e.Reason == t.Reason && e.isTemp == t.isTemp
|
||||||
}
|
}
|
||||||
return e.Reason == t.Reason && e.isTemp == t.isTemp
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// String implements the Stringer interface for the SendErrReason
|
// String implements the Stringer interface for the SendErrReason
|
||||||
|
|
Loading…
Reference in a new issue