Skip to content

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

@github-actions
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! 😄

@manuelmeurer
Copy link
Contributor Author

Could someone review this PR and give me some feedback?

@nickfloyd nickfloyd moved this from 🆕 Triage to 👀 In review in 🧰 Octokit Active Jun 3, 2025
@manuelmeurer
Copy link
Contributor Author

@nickfloyd Any chance to get a review of this PR?

Copy link
Contributor

@nickfloyd nickfloyd left a comment

Choose a reason for hiding this comment

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

❤️

@nickfloyd nickfloyd merged commit fb2f208 into octokit:main Sep 18, 2025
2 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in 🧰 Octokit Active Sep 18, 2025
@manuelmeurer manuelmeurer deleted the errors branch September 18, 2025 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

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

2 participants