Update error handling to include error code and status

Previously, only the isTemp flag was considered when aggregating errors. Now, the error code and enhanced status code from the last error are also included. This ensures more comprehensive error reporting and handling.
This commit is contained in:
Winni Neessen 2024-11-13 23:04:39 +01:00
parent 719e5b217c
commit a5ac7c3370
Signed by: wneessen
GPG key ID: 385AC9889632126E

View file

@ -55,9 +55,11 @@ func (c *Client) Send(messages ...*Msg) error {
returnErr.rcpt = append(returnErr.rcpt, errs[i].rcpt...) returnErr.rcpt = append(returnErr.rcpt, errs[i].rcpt...)
} }
// We assume that the isTemp flag from the last error we received should be the // We assume that the error codes and flags from the last error we received should be the
// indicator for the returned isTemp flag as well // indicator for the returned isTemp flag as well
returnErr.isTemp = errs[len(errs)-1].isTemp returnErr.isTemp = errs[len(errs)-1].isTemp
returnErr.errcode = errs[len(errs)-1].errcode
returnErr.enhancedStatusCode = errs[len(errs)-1].enhancedStatusCode
return returnErr return returnErr
} }