Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chuyeow/try
Extensions to Ruby's Kernel that allow for retryable blocks of code.
https://github.com/chuyeow/try
Last synced: about 2 months ago
JSON representation
Extensions to Ruby's Kernel that allow for retryable blocks of code.
- Host: GitHub
- URL: https://github.com/chuyeow/try
- Owner: chuyeow
- Created: 2008-09-17T14:22:30.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2008-09-17T14:47:16.000Z (over 16 years ago)
- Last Synced: 2024-11-07T20:16:14.117Z (3 months ago)
- Language: Ruby
- Homepage: http://blog.codefront.net/2008/01/14/retrying-code-blocks-in-ruby-on-exceptions-whatever/
- Size: 78.1 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
= try
Extensions to Kernel that allow for retryable blocks of code.
== Examples
* Kernel#retryable
retryable(:tries => 3, :on => StandardError) do
# Some code that could fail, like connecting to a flakey API.
end* Kernel#try
try(
some_method_that_could_fail,
Proc.new { raise RuntimeError unless moon.is_blue? },
'some fallback value if all things fail'
)