forked from truemail-rb/truemail-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
41 lines (33 loc) · 1.06 KB
/
error.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package truemail
import "net"
// Error wrapper
type validationError struct {
isDnsNotFound, isNullMxFound bool
err error
}
// error interface implementation
func (customError *validationError) Error() string {
return customError.err.Error()
}
// Wrappes error in validationError with isNullMxFound: true
func wrapNullMxError(err error) *validationError {
return &validationError{isNullMxFound: true, err: err}
}
// Wrappes DNSError in validationError with isDnsNotFound,
// that depends on DNSError context
func wrapDnsError(err error) *validationError {
e, ok := err.(*net.DNSError)
if ok && e.IsNotFound {
return &validationError{isDnsNotFound: true, err: err}
}
return &validationError{err: err}
}
// SMTP client custom error wrapper
type SmtpClientError struct {
isConnection, isResponseTimeout, isHello, isMailFrom, isRecptTo bool
err error
}
// error interface implementation
func (smtpClientError *SmtpClientError) Error() string {
return smtpClientError.err.Error()
}