mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-24 14:40:49 +01:00
Add ErrorCode method to SendError
Implemented ErrorCode method to retrieve the error code from the server response in SendError. This method distinguishes between server-generated errors and client-generated errors, returning 0 for errors generated by the client.
This commit is contained in:
parent
b9d9449252
commit
ad265cac57
1 changed files with 15 additions and 0 deletions
15
senderror.go
15
senderror.go
|
@ -200,6 +200,21 @@ func (e *SendError) EnhancedStatusCode() string {
|
|||
return e.enhancedStatusCode
|
||||
}
|
||||
|
||||
// ErrorCode returns the error code of the server response.
|
||||
//
|
||||
// This function retrieves the error code the error returned by the server. The error code will
|
||||
// start with 5 on permanent errors and with 4 on a temporary error. If the error is not returned
|
||||
// by the server, but is generated by go-mail, the code will be 0.
|
||||
//
|
||||
// Returns:
|
||||
// - The error code as returned by the server, or 0 if not a server error.
|
||||
func (e *SendError) ErrorCode() int {
|
||||
if e == nil {
|
||||
return 0
|
||||
}
|
||||
return e.errcode
|
||||
}
|
||||
|
||||
// String satisfies the fmt.Stringer interface for the SendErrReason type.
|
||||
//
|
||||
// This function converts the SendErrReason into a human-readable string representation based
|
||||
|
|
Loading…
Reference in a new issue