-
Notifications
You must be signed in to change notification settings - Fork 4
Closed
Labels
Status: TriageThis is being looked at and prioritizedThis is being looked at and prioritizedType: FeatureNew feature or requestNew feature or request
Description
Describe the need
I often use Octopoller to run some code that might raise a specific error (or one of multiple specific errors) and retry a few times if that errors happens:
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.
endThis is quite ugly and hard to read, though.
I propose we add a errors parameter that lets us do this instead:
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`.
endMuch easier to read and the cause of Octopoller::TooManyAttemptsError (and Octopoller::TimeoutError) is set properly.
SDK Version
No response
API Version
No response
Relevant log output
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
Status: TriageThis is being looked at and prioritizedThis is being looked at and prioritizedType: FeatureNew feature or requestNew feature or request
Type
Projects
Status
✅ Done