class Pione::Command::ExceptionHandler

‘ExceptionHandler` is a handler of exception for action item.

Public Class Methods

new(exceptions, block) click to toggle source
# File lib/pione/command/common.rb, line 179
def initialize(exceptions, block)
  @exceptions = exceptions
  @block = block
end

Public Instance Methods

handle(context, e, *args) click to toggle source
# File lib/pione/command/common.rb, line 193
def handle(context, e, *args)
  context.instance_exec(e, *args, &@block)
end
try_to_handle(context, e, *args) click to toggle source
# File lib/pione/command/common.rb, line 184
def try_to_handle(context, e, *args)
  if @exceptions.any?{|ec| e.kind_of?(ec)}
    handle(context, e, *args)
    return true
  end

  return false
end