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

Skip retries for defined SlackAPIErrorCode #4913

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

jschroth
Copy link
Contributor

@jschroth jschroth commented Jul 3, 2024

Does not retry for any item in the SlackAPIErrorCode enum

Does not retry for any item in the SlackAPIErrorCode enum
Copy link
Contributor

@whitdog47 whitdog47 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@whitdog47 whitdog47 added the bug Something isn't working label Jul 3, 2024
@jschroth jschroth merged commit ec1847c into master Jul 3, 2024
8 of 9 checks passed
@jschroth jschroth deleted the bug/slackretry_skipknown branch July 3, 2024 19:19
@wssheldon
Copy link
Contributor

You should be able to simplify this down to:

def should_retry(exception: Exception) -> bool:
    match exception:
        case SlackApiError():
            return exception.response["error"] not in SlackAPIErrorCode.__members__.values()
        case TimeoutError() | Timeout():
            return True
        case _:
            return False

@wssheldon
Copy link
Contributor

We could also implement __contains__ on DispatchEnum to allow exception.response["error"] not in SlackAPIErrorCode

metroid-samus pushed a commit that referenced this pull request Sep 25, 2024
Does not retry for any item in the SlackAPIErrorCode enum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants