Rescuer
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
- Add any missing test to ensure exception rescuing matches all the same cases in Scala's
Try
class - Come up with output for
#to_s
and#inspect
that I like - Document using yard
- Release 0.9.0 and solicit comments
- Incorporate suggested changes
- Release 1.0.0
- Potentially incorporate as a depedendency into Rumonade