mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-24 22:50:49 +01:00
Add error handling for nil DialContextFunc
Introduce ErrDialContextFuncIsNil to handle cases where the dial context function is not provided. Update WithDialContextFunc to return this error when a nil function is passed.
This commit is contained in:
parent
3251d74c36
commit
35f92f2ddc
1 changed files with 6 additions and 0 deletions
|
@ -245,6 +245,9 @@ var (
|
|||
|
||||
// ErrSMTPAuthMethodIsNil indicates that the SMTP authentication method provided is nil
|
||||
ErrSMTPAuthMethodIsNil = errors.New("SMTP auth method is nil")
|
||||
|
||||
// ErrDialContextFuncIsNil indicates that a required dial context function is not provided.
|
||||
ErrDialContextFuncIsNil = errors.New("dial context function is nil")
|
||||
)
|
||||
|
||||
// NewClient creates a new Client instance with the provided host and optional configuration Option functions.
|
||||
|
@ -677,6 +680,9 @@ func WithoutNoop() Option {
|
|||
// - An Option function that sets the custom DialContextFunc for the Client.
|
||||
func WithDialContextFunc(dialCtxFunc DialContextFunc) Option {
|
||||
return func(c *Client) error {
|
||||
if dialCtxFunc == nil {
|
||||
return ErrDialContextFuncIsNil
|
||||
}
|
||||
c.dialContextFunc = dialCtxFunc
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue