Skip to content

Commit

Permalink
Document new :exception_cb parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
nfedyashev committed Feb 1, 2014
1 parent e3c93cf commit 8de7385
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Description
Runs a code block, and retries it when an exception occurs. It's great when
working with flakey webservices (for example).

It's configured using four optional parameters `:tries`, `:on`, `:sleep`, `:matching`, `:ensure` and
It's configured using four optional parameters `:tries`, `:on`, `:sleep`, `:matching`, `:ensure`, `:exception_cb` and
runs the passed block. Should an exception occur, it'll retry for (n-1) times.

Should the number of retries be reached without success, the last exception
Expand Down Expand Up @@ -56,7 +56,7 @@ end

## Defaults

:tries => 2, :on => StandardError, :sleep => 1, :matching => /.*/, :ensure => Proc.new { }
:tries => 2, :on => StandardError, :sleep => 1, :matching => /.*/, :ensure => Proc.new { }, :exception_cb => Proc.new { }

Sleeping
--------
Expand Down Expand Up @@ -89,6 +89,17 @@ retryable do |retries, exception|
end
```

Callback to run after an exception is rescued
--------
exception_cb = Proc.new do |exception|
ExceptionNotifier.notify_exception(exception, :data => {:message => "it failed"}) # http://smartinez87.github.io/exception_notification
end

retryable(:exception_cb => exception_cb) do
# perform risky operation
end


You can temporary disable retryable blocks
--------

Expand Down

0 comments on commit 8de7385

Please sign in to comment.