Class: Pione::Command::ExceptionHandler
- Inherits:
-
Object
- Object
- Pione::Command::ExceptionHandler
- Defined in:
- lib/pione/command/common.rb
Overview
ExceptionHandler
is a handler of exception for action item.
Instance Method Summary collapse
- #handle(context, e, *args) ⇒ Object
-
#initialize(exceptions, block) ⇒ ExceptionHandler
constructor
A new instance of ExceptionHandler.
- #try_to_handle(context, e, *args) ⇒ Object
Constructor Details
#initialize(exceptions, block) ⇒ ExceptionHandler
Returns a new instance of ExceptionHandler.
179 180 181 182 |
# File 'lib/pione/command/common.rb', line 179 def initialize(exceptions, block) @exceptions = exceptions @block = block end |
Instance Method Details
#handle(context, e, *args) ⇒ Object
193 194 195 |
# 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) ⇒ Object
184 185 186 187 188 189 190 191 |
# 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 |