-
Notifications
You must be signed in to change notification settings - Fork 2
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
Throw typed exceptions #6
Comments
It looks like this was taken care of already, e.g.: #7 -- is there more to do here? |
The SDK currently throws However, a similar effect can also be accomplished with the when clause: try
{
await _resend.EmailSendAsync( ... );
}
catch ( ResendException ex ) when ( ex.ErrorType == ErrorType.RateLimitExceeded )
{
Console.Error.WriteLine( "Rate limit exceeded: please wait before retrying" );
}
catch ( ResendException ex )
{
Console.Error.WriteLine( "err: {0} - {1}", ex.ErrorType, ex.Message );
} Having said that, a specialized Console.Error.WriteLine( "Rate limit exceeded: please wait {0}s before retrying", ex.Limits?.RetryAfter ); |
Thanks for the explanation, @filipetoscano I took a shot at adding ResendRateLimitExceededException and using it once. I wanted to check if I'm on the right track before adding more. PR: #18 I also added an option to auto retry, since we know how long the client needs to wait before retrying. This can be disabled if users don't want this functionality. I'm learning C# and using this as a way to practice, so if this is way off, you can just ignore me. But if it's close enough to be helpful I'd appreciate your feedback! |
Current:
After:
ResendException
(derived) exceptionsThe text was updated successfully, but these errors were encountered: