Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature(sendError): add unwrap interface #356

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sonalys
Copy link
Contributor

@sonalys sonalys commented Nov 7, 2024

Just a brief description of my problem:

I'm trying to validate if a FROM address is valid, and I'm looking into the SMTP Error codes.
I noticed that you receive the error codes, and hide then behind the SendError struct.

It would be helpful for me to have a direct access to these error codes through textproto.Error, instead of parsing them from the error message.

We Have the errors.As function, that tries to go error to error from the error stack, until the type assertion Matches.
I'm implementing the Unwrap interface on SendError for that reason, so we can do errors.As and extract any internal error from the SendError struct.

Another possible solution would be if you also stored the ErrorCode on the SendError struct.

@wneessen
Copy link
Owner

wneessen commented Nov 7, 2024

Thanks for the PR @sonalys. I am fine with adding the Unwrap() on SendError but if your main concern is the error code, I agree that adding the error code into the senderror struct would be the better solution. I'll create an issue for us to add this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants