class EHandl::ExceptionHandling

Attributes

value[R]

Public Class Methods

new(handlers, default_handler) { || ... } click to toggle source
# File lib/ehandl.rb, line 44
def initialize handlers, default_handler
  begin 
    @value = yield()
  rescue Exception => ex
    @value = ex
    if(handlers[ex.class].nil?)
      default_handler.call(ex)
    else
      handlers[ex.class].call(ex)
    end
  end
  @value
end