class MyApiClient::ErrorHandling::RetryOptionProcessor
Processes the `retry` option.
Attributes
error_handling_options[R]
Public Class Methods
new(error_handling_options:)
click to toggle source
@param error_handling_options
[Hash]
Options for the retry.
@option raise [MyApiClient::Error]
Raises specified error when an invalid response detected. Should be inherited `MyApiClient::Error` class.
@option retry [TrueClass, Hash]
If the error detected, retries the API request. Requires `raise` option. You can set `true` or `retry_on` options (`wait` and `attempts`).
@option block [Proc, nil]
Executes the block when error detected. The `block` option is forbidden to be used with the` retry` option.
@return [Hash]
Options for `retry_on`.
@return [nil]
If `retry` is not specified.
# File lib/my_api_client/error_handling/retry_option_processor.rb, line 22 def initialize(error_handling_options:) @error_handling_options = error_handling_options end
Private Instance Methods
call()
click to toggle source
# File lib/my_api_client/error_handling/retry_option_processor.rb, line 30 def call retry_options = error_handling_options.delete(:retry) return unless retry_options verify_error_handling_options retry_options = {} unless retry_options.is_a? Hash retry_options end
verify_error_handling_options()
click to toggle source
Requires `retry` option and forbid `block` option.
# File lib/my_api_client/error_handling/retry_option_processor.rb, line 40 def verify_error_handling_options if !error_handling_options[:raise] raise 'The `retry` option requires `raise` option. ' \ 'Please set any `raise` option, which inherits `MyApiClient::Error` class.' elsif error_handling_options[:block] raise 'The `block` option is forbidden to be used with the` retry` option.' end end