Rescuer

Gem Version Build Status Dependency Status Code Climate Coverage Status

A functional abstraction of rescuing exceptions inspired by Scala's Try class (here's an explanation).

Usage

denominators = [0, 1]

fractions = denominators.map { |d| Rescuer.new { 1 / d } }
#=> [#<struct Rescuer::Failure exception=#<ZeroDivisionError: divided by 0>, exceptions_to_rescue=nil>,
#    #<struct Rescuer::Success value=1, exceptions_to_rescue=nil>]

More coming soon...

TODO

  1. Add any missing test to ensure exception rescuing matches all the same cases in Scala's Try class
  2. Come up with output for #to_s and #inspect that I like
  3. Document using yard
  4. Release 0.9.0 and solicit comments
  5. Incorporate suggested changes
  6. Release 1.0.0
  7. Potentially incorporate as a depedendency into Rumonade