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

Change Status when validation fails. #42

Closed
atheken opened this issue Dec 2, 2016 · 1 comment
Closed

Change Status when validation fails. #42

atheken opened this issue Dec 2, 2016 · 1 comment

Comments

@atheken
Copy link
Contributor

atheken commented Dec 2, 2016

When validation fails in the postmark client, the PostmarkResponse class has a status of success. This is not really correct. It should be changed to "ValidationError" or similar, so that it can be identified more easily by the consumers of the client.

We should also add an option to the client to cause ValidationErrors to throw exceptions, as an alternative to checking the status codes, this would be backwards compatible with the current handling, which doesn't throw exceptions.

@tomasr78
Copy link

tomasr78 commented Feb 24, 2020

You should remove Exceptions completely if you provide Enum Status. Use Exceptions for errors or Status but not both as Library does now!

#77

Our current implementation, to skip that annoying Exception and not break execution we wrap exception.

public async Task<(bool result, string Message)> MailAsync(string recipientName, string recipientEmail, int templateId,
            Dictionary<string, object> model)
        {
            //Skip code
            var result = new PostmarkResponse();
            try
            {
                result = await client.SendMessageAsync(message);
            }
            catch (PostmarkValidationException e)
            {
                result.Status = PostmarkStatus.ServerError;
                result.Message = e.Message;
            }

            return (result.Status == PostmarkStatus.Success, result.Message);
        }

@atheken atheken closed this as completed Apr 3, 2024
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

No branches or pull requests

2 participants