Skip to content

Add errors parameter #48

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

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

Conversation

manuelmeurer
Copy link
Contributor

@manuelmeurer manuelmeurer commented Mar 21, 2025

Resolves #47


Before the change?

MyError = Class.new(StandardError)

begin
  Octopoller.poll retries: 3 do
    # Do something that might raise MyError.
  rescue MyError => cause_error
    :re_poll
  end
rescue Octopoller::TooManyAttemptsError => error
  # To access the error, which caused the Octopoller::TooManyAttemptsError,
  # I must access `cause_error`, since `error.cause` is nil.
end

After the change?

MyError = Class.new(StandardError)

begin
  Octopoller.poll retries: 3, errors: [MyError] do
    # Do something that might raise MyError.
    # It will be retried 3 times automatically.
  end
rescue Octopoller::TooManyAttemptsError => error
  # Here I can access the error, which caused the Octopoller::TooManyAttemptsError,
  # via `error.cause`.
end

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

Copy link

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@manuelmeurer
Copy link
Contributor Author

I haven't added tests or updated the docs yet, happy to do so if this feature is welcomed! 😄

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

Successfully merging this pull request may close these issues.

[FEAT]: Simplify use-case "retry on errors"
1 participant